KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > junit > swingui > StatusLine


1 package junit.swingui;
2
3 import java.awt.Color JavaDoc;
4 import java.awt.Dimension JavaDoc;
5 import java.awt.Font JavaDoc;
6
7 import javax.swing.BorderFactory JavaDoc;
8 import javax.swing.JTextField JavaDoc;
9 import javax.swing.border.BevelBorder JavaDoc;
10
11 /**
12  * A status line component.
13  */

14 public class StatusLine extends JTextField JavaDoc {
15     public static final Font JavaDoc PLAIN_FONT= new Font JavaDoc("dialog", Font.PLAIN, 12);
16     public static final Font JavaDoc BOLD_FONT= new Font JavaDoc("dialog", Font.BOLD, 12);
17
18     public StatusLine(int preferredWidth) {
19         super();
20         setFont(BOLD_FONT);
21         setEditable(false);
22         setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
23         Dimension JavaDoc d= getPreferredSize();
24         d.width= preferredWidth;
25         setPreferredSize(d);
26     }
27     
28     public void showInfo(String JavaDoc message) {
29         setFont(PLAIN_FONT);
30         setForeground(Color.black);
31         setText(message);
32     }
33     
34     public void showError(String JavaDoc status) {
35         setFont(BOLD_FONT);
36         setForeground(Color.red);
37         setText(status);
38         setToolTipText(status);
39     }
40     
41     public void clear() {
42         setText("");
43         setToolTipText(null);
44     }
45 }
Popular Tags