This repository was archived by the owner on Nov 16, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathloadSpinner.java
More file actions
72 lines (59 loc) · 1.96 KB
/
loadSpinner.java
File metadata and controls
72 lines (59 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* By attaching this document to the given files (the �work�), you, the licensee,
* are hereby granted free usage in both personal and commerical environments,
* without any obligation of attribution or payment (monetary or otherwise).
*
* The licensee is free to use, copy, modify, publish, distribute, sublicence,
* and/or merchandise the work, subject to the licensee inflecting a positive
* message unto someone. This includes (but is not limited to): smiling,
* being nice, saying �thank you�, assisting other persons, or any
* similar actions percolating the given concept.
*
* The above copyright notice serves as a permissions notice also,
* and may optionally be included in copies or portions of the work.
*
* The work is provided �as is�, without warranty or support, express or implied.
* The author(s) are not liable for any damages, misuse, or other claim, whether
* from or as a consequence of usage of the given work.
*/
package Proiect;
import java.awt.*;
import javax.swing.*;
/**
* This class opens a transparent window that loads the spinner
*
* @author Stefan Cosma
*
*/
public class loadSpinner extends JWindow {
private static final long serialVersionUID = 1L;
private int duration;
Image bi = Toolkit.getDefaultToolkit().getImage(
getClass().getClassLoader().getResource("assets/loader.gif"));
ImageIcon ii = new ImageIcon(bi);
public loadSpinner(int d) {
duration = d;
}
public void showLoader() {
int width = 31;
int height = 31;
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
int x = (screen.width - width) / 2;
int y = (screen.height - height) / 2;
setBounds(x, y, width, height);
setBackground(new Color(255, 255, 255, 0));
setVisible(true);
try {
Thread.sleep(duration);
} catch (Exception e) {
}
setVisible(false);
}
public void showLoaderAndExit() {
showLoader();
dispose();
}
public void paint(Graphics g) {
g.drawImage(bi, 0, 0, this);
}
}