JPnlHeader.java
2.33 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package org.emercit.components;
import java.awt.Color;
import javax.swing.JLabel;
import javax.swing.JButton;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Font;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.border.Border;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class JPnlHeader extends RoundedPanel3 {
private JLabel jlblclock;
private JLabel jlbltitle;
private JLabel jlblconnect;
private JButton jbtnExit;
public JPnlHeader(String title) {
this.setLayout(null);
// время
jlblclock = new JLabel();
jlblclock.setBounds(5, 2, 300, 30);
jlblclock.setText("Сегодня:03.03.2014 08:55:33");
jlblclock.setFont(new Font(null, Font.ITALIC, 13));
jlblclock.setForeground(Color.YELLOW);
jlblclock.setIcon(new ImageIcon(this.getClass().getResource(
"/clock.png")));
add(jlblclock);
// название
jlbltitle = new JLabel();
jlbltitle.setBounds(320, 2, 250, 30);
jlbltitle.setText(title);
jlbltitle.setFont(new Font(null, Font.ITALIC, 13));
jlbltitle.setForeground(Color.YELLOW);
add(jlbltitle);
// connect
jlblconnect = new JLabel();
jlblconnect.setBounds(600, 5, 50, 30);
ChangeConnectImg(false);
add(jlblconnect);
// exit
jbtnExit = new JButton("Выход");
jbtnExit.setText("ВЫХОД");
jbtnExit.addActionListener(new exitApp());
jbtnExit.setBounds(650, 5, 100, 30);
// add(jbtnExit);
}
static class exitApp implements ActionListener {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
}
/*
* Обновляем время
*/
public void UpdateTime(String val) {
jlblclock.setText(val);
}
public void SetBlue() {
setBackground(new Color(168, 181, 224));
}
public void ChangeConnectImg(boolean connect) {
if (connect) {
jlblconnect.setIcon(new ImageIcon(this.getClass().getResource(
"/connect_service.png")));
} else {
jlblconnect.setIcon(new ImageIcon(this.getClass().getResource(
"/disconnect_service.png")));
}
this.repaint();
}
public void setTitleSubscriver(String title) {
try {
jlbltitle.setText(title);
}
catch(Exception e) {
}
}
}