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