aboutsummaryrefslogtreecommitdiff
path: root/src/junit/swingui/StatusLine.java
blob: e18fda241b0bfbcdd3f80d49ba012cd7901a9b6e (plain)
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
package junit.swingui;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;

import javax.swing.BorderFactory;
import javax.swing.JTextField;
import javax.swing.border.BevelBorder;

/**
 * A status line component.
 */
public class StatusLine extends JTextField {
	public static final Font PLAIN_FONT= new Font("dialog", Font.PLAIN, 12);
	public static final Font BOLD_FONT= new Font("dialog", Font.BOLD, 12);

	public StatusLine(int preferredWidth) {
		super();
		setFont(BOLD_FONT);
		setEditable(false);
		setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
		Dimension d= getPreferredSize();
		d.width= preferredWidth;
		setPreferredSize(d);
	}
	
	public void showInfo(String message) {
		setFont(PLAIN_FONT);
		setForeground(Color.black);
		setText(message);
	}
	
	public void showError(String status) {
		setFont(BOLD_FONT);
		setForeground(Color.red);
		setText(status);
		setToolTipText(status);
	}
	
	public void clear() {
		setText("");
		setToolTipText(null);
	}
}