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 |
| package com.jeantessier.dependencyfinder.gui; |
34 |
| |
35 |
| import java.awt.*; |
36 |
| import javax.swing.*; |
37 |
| import javax.swing.border.*; |
38 |
| |
39 |
| public class StatusLine extends JTextField { |
40 |
| public static final Font PLAIN_FONT = new Font("dialog", Font.PLAIN, 12); |
41 |
| public static final Font BOLD_FONT = new Font("dialog", Font.BOLD, 12); |
42 |
| |
43 |
0
| public StatusLine(int preferredWidth) {
|
44 |
0
| setFont(BOLD_FONT);
|
45 |
0
| setEditable(false);
|
46 |
0
| setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
|
47 |
0
| Dimension d = getPreferredSize();
|
48 |
0
| d.width = preferredWidth;
|
49 |
0
| setPreferredSize(d);
|
50 |
| } |
51 |
| |
52 |
0
| public void showInfo(String message) {
|
53 |
0
| SwingUtilities.invokeLater(new StatusLineUpdater(this, PLAIN_FONT, Color.black, message, message));
|
54 |
| } |
55 |
| |
56 |
0
| public void showError(String status) {
|
57 |
0
| SwingUtilities.invokeLater(new StatusLineUpdater(this, BOLD_FONT, Color.red, status, status));
|
58 |
| } |
59 |
| |
60 |
0
| public void clear() {
|
61 |
0
| SwingUtilities.invokeLater(new StatusLineUpdater(this, PLAIN_FONT, Color.black, "", null));
|
62 |
| } |
63 |
| } |
64 |
| |
65 |
| class StatusLineUpdater implements Runnable { |
66 |
| private StatusLine statusLine; |
67 |
| private Font font; |
68 |
| private Color color; |
69 |
| private String message; |
70 |
| private String tooltip; |
71 |
| |
72 |
0
| public StatusLineUpdater(StatusLine statusLine, Font font, Color color, String message, String tooltip) {
|
73 |
0
| this.statusLine = statusLine;
|
74 |
0
| this.font = font;
|
75 |
0
| this.color = color;
|
76 |
0
| this.message = message;
|
77 |
0
| this.tooltip = tooltip;
|
78 |
| } |
79 |
| |
80 |
0
| public void run() {
|
81 |
0
| statusLine.setFont(font);
|
82 |
0
| statusLine.setForeground(color);
|
83 |
0
| statusLine.setText(message);
|
84 |
0
| statusLine.setToolTipText(tooltip);
|
85 |
| } |
86 |
| } |