-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExitButton.java
More file actions
executable file
·80 lines (68 loc) · 2.26 KB
/
ExitButton.java
File metadata and controls
executable file
·80 lines (68 loc) · 2.26 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
73
74
75
76
77
78
79
80
/*
* Projet : Trustopics
* Version : 0.2.1
* Fichier : ExitButton.java
*/
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.Timer;
import javax.swing.BorderFactory;
import javax.swing.JButton;
public class ExitButton extends JButton implements MouseListener,ActionListener {
private final Color glb_colText = Defines.UIcolForeGDrawingCDE1.brighter();
private final Color glb_colBack = Defines.UIcolForeGDrawingCDE2.darker();
private final int glb_widthStroke = 6;
private Color glb_colTextBak;
private Color glb_colBackBak;
private Timer glb_timer;
public ExitButton(Timer prm_timer) {
glb_timer = prm_timer;
glb_colTextBak = glb_colText;
glb_colBackBak = glb_colBack;
addMouseListener(this);
addActionListener(this);
setBorder(BorderFactory.createEmptyBorder());
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
g2.setPaint(glb_colBackBak);
g2.fillRect(0,0,getWidth(),getHeight());
g2.setStroke( new BasicStroke(glb_widthStroke,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND));
g2.setPaint(glb_colTextBak);
g2.drawLine(glb_widthStroke,glb_widthStroke,getWidth()-glb_widthStroke,getHeight()-glb_widthStroke);
g2.drawLine(getWidth()-glb_widthStroke,glb_widthStroke,glb_widthStroke,getHeight()-glb_widthStroke);
}
public void mouseEntered(MouseEvent prm_evt) {
glb_colTextBak = glb_colBack;
glb_colBackBak = glb_colText;
update(getGraphics());
}
public void mouseExited(MouseEvent prm_evt) {
glb_colTextBak = glb_colText;
glb_colBackBak = glb_colBack;
update(getGraphics());
}
public void mouseClicked(MouseEvent prm_evt) {
}
public void mousePressed(MouseEvent prm_evt) {
glb_colTextBak = glb_colBack;
glb_colBackBak = glb_colText.brighter();
}
public void mouseReleased(MouseEvent prm_evt) {
}
public void actionPerformed(ActionEvent prm_evt) {
if (!Defines.topicsUpdateIsInProgress) {
glb_timer.cancel();
System.exit(0);
}
}
}