1 package junit.swingui; 2 3 import java.awt.Color ; 4 import java.awt.Dimension ; 5 import java.awt.Font ; 6 7 import javax.swing.BorderFactory ; 8 import javax.swing.JTextField ; 9 import javax.swing.border.BevelBorder ; 10 11 14 public class StatusLine extends JTextField { 15 public static final Font PLAIN_FONT= new Font ("dialog", Font.PLAIN, 12); 16 public static final Font BOLD_FONT= new Font ("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 d= getPreferredSize(); 24 d.width= preferredWidth; 25 setPreferredSize(d); 26 } 27 28 public void showInfo(String message) { 29 setFont(PLAIN_FONT); 30 setForeground(Color.black); 31 setText(message); 32 } 33 34 public void showError(String 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 |