FileDocCategorySizeDatePackage
Diagnostic.javaAPI DocExample2094Mon Nov 09 12:45:52 GMT 1998None

Diagnostic

public class Diagnostic extends Object

Fields Summary
private JTextPane
pane
Constructors Summary
public Diagnostic()

    pane = new JTextPane();
    pane.setBackground(Color.black);
    pane.setEditable(false);
  
Methods Summary
public java.awt.ComponentgetComponent()

 return pane; 
public static voidmain(java.lang.String[] args)

    Diagnostic diag = new Diagnostic();
    JFrame f = new JFrame();
    f.addWindowListener(new BasicWindowMonitor());
    f.getContentPane().add(diag.getComponent());
    f.setSize(300,200);
    f.setVisible(true);

    // Display a few messages...
    diag.showInfo("System normal");
    diag.showWarning("Disk space low");
    diag.showError("Out of memory");
    diag.showError("Program performed an illegal operation");
    diag.showInfo("System normal");
  
public voidshowError(java.lang.String msg)

    SimpleAttributeSet attrs = new SimpleAttributeSet();
    StyleConstants.setForeground(attrs, Color.red);
    StyleConstants.setItalic(attrs, true);
    StyleConstants.setBold(attrs, true);
    showMsg(msg, attrs);
  
public voidshowInfo(java.lang.String msg)

    SimpleAttributeSet attrs = new SimpleAttributeSet();
    StyleConstants.setForeground(attrs, Color.green);
    showMsg(msg, attrs);
  
protected voidshowMsg(java.lang.String msg, javax.swing.text.AttributeSet attrs)

    Document doc = pane.getDocument();
    msg += "\n";
    try {
      doc.insertString(doc.getLength(), msg, attrs);
    } catch (BadLocationException ex) { ex.printStackTrace(); }
  
public voidshowWarning(java.lang.String msg)

    SimpleAttributeSet attrs = new SimpleAttributeSet();
    StyleConstants.setForeground(attrs, Color.yellow);
    StyleConstants.setItalic(attrs, true);
    showMsg(msg, attrs);