1 package junit.swingui; 2 3 import java.awt.*; 4 5 import javax.swing.*; 6 import javax.swing.border.BevelBorder; 7 8 /*** 9 * A status line component. 10 */ 11 public class StatusLine extends JTextField { 12 public static final Font PLAIN_FONT= new Font("dialog", Font.PLAIN, 12); 13 public static final Font BOLD_FONT= new Font("dialog", Font.BOLD, 12); 14 15 public StatusLine(int preferredWidth) { 16 super(); 17 setFont(BOLD_FONT); 18 setEditable(false); 19 setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); 20 Dimension d= getPreferredSize(); 21 d.width= preferredWidth; 22 setPreferredSize(d); 23 } 24 25 public void showInfo(String message) { 26 setFont(PLAIN_FONT); 27 setForeground(Color.black); 28 setText(message); 29 } 30 31 public void showError(String status) { 32 setFont(BOLD_FONT); 33 setForeground(Color.red); 34 setText(status); 35 setToolTipText(status); 36 } 37 38 public void clear() { 39 setText(""); 40 setToolTipText(null); 41 } 42 }