Horus Doc || Java GUI Reference || Doxygen's quick Index  

ErrorStreamArea Class Reference

An area for error messages. More...

Inheritance diagram for ErrorStreamArea::

AppletErrorStreamArea List of all members.

Public Methods

 ErrorStreamArea (JFrame parent, int rows, int columns)
 Constructor. More...

 ErrorStreamArea (JFrame parent, int rows, int columns, boolean capture)
 Constructor. More...

void capture ()
 capture redirects all the output to the TextArea. More...

void actionPerformed (ActionEvent e)
 Implementation of ActionListener. More...


Static Public Methods

void print (String str)
 Displays the given string (without printing a newline). More...

void println (String str)
 Displays the given string and a newline. More...


Protected Methods

void doPrint (String str)
void doPrintln (String str)
void doClear ()
native void initGuiErrorStream ()

Detailed Description

An area for error messages.


Constructor & Destructor Documentation

ErrorStreamArea::ErrorStreamArea JFrame    parent,
int    rows,
int    columns
[inline]
 

Constructor.

00028 {
00029     this(parent, rows, columns, true);
00030 }

ErrorStreamArea::ErrorStreamArea JFrame    parent,
int    rows,
int    columns,
boolean    capture
[inline]
 

Constructor.

00035 {
00036     if(capture) _theOutput = this;
00037 
00038     _parent = parent;
00039 
00040     setLayout(new GridBagLayout());
00041 
00042     JLabel label = new JLabel("ErrorStream Area   ");
00043     addGridComp(this, label, 0, 0, 1, 1,
00044                 GridBagConstraints.NONE, 0.0, 0.0, 1, 1);
00045 
00046     _popOnError = new JCheckBox("PopDialogOnError", true);
00047     addGridComp(this, _popOnError, 1, 0, 1, 1,
00048                GridBagConstraints.NONE, 0.0, 0.0, 1, 1);
00049 
00050     _bClear = new JButton("Clear");
00051     _bClear.addActionListener(this);
00052     addGridComp(this, _bClear, 2, 0, 1, 1,
00053                 GridBagConstraints.NONE, 0.0, 0.0, 1, 1);
00054 
00055     _text = new JTextArea(rows, columns);
00056     _text.setEditable(false);
00057     JScrollPane scrollPane = new JScrollPane(_text,
00058                                     JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
00059                                     JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
00060     addGridComp(this, scrollPane, 0, 1, 10, 1,
00061                 GridBagConstraints.BOTH, 1.0, 1.0, 1, 1);
00062 
00063     //initGuiErrorStream();
00064 }


Member Function Documentation

void ErrorStreamArea::capture   [inline]
 

capture redirects all the output to the TextArea.

This method is helpful when an ErrorStreamArea is created and you wait till the containing frame is shown to redirect the output (in the meantime all the output goes to the console).

00071 {
00072     _theOutput = this;
00073 }

void ErrorStreamArea::actionPerformed ActionEvent    e [inline]
 

Implementation of ActionListener.

00079 {
00080     if (e.getSource() == _bClear)
00081         doClear();
00082 }

void ErrorStreamArea::print String    str [inline, static]
 

Displays the given string (without printing a newline).

00088 {
00089     if (_theOutput != null) {
00090         _theOutput.doPrint(str);
00091 
00092     } else {
00093         System.err.print(str);
00094     }
00095 }

void ErrorStreamArea::println String    str [inline, static]
 

Displays the given string and a newline.

00101 {
00102     if (_theOutput != null) {
00103         _theOutput.doPrintln(str);
00104     } else {
00105         System.err.println(str);
00106     }
00107 }

void ErrorStreamArea::doPrint String    str [inline, protected]
 

00110 {
00111     _text.append(str);
00112     if(_popOnError.isSelected()) {
00113         JOptionPane.showMessageDialog(_theOutput._parent, str, "Error",
00114             JOptionPane.ERROR_MESSAGE);
00115     }
00116 }

void ErrorStreamArea::doPrintln String    str [inline, protected]
 

00119 {
00120     _text.append(str + "\n");
00121     if(_popOnError.isSelected()) {
00122         JOptionPane.showMessageDialog(_theOutput._parent, str, "Error",
00123             JOptionPane.ERROR_MESSAGE);
00124     }
00125 }

void ErrorStreamArea::doClear   [inline, protected]
 

Reimplemented in AppletErrorStreamArea.

00128 {
00129     _text.setText("");
00130 }

native void ErrorStreamArea::initGuiErrorStream   [protected]
 

Reimplemented in AppletErrorStreamArea.


The documentation for this class was generated from the following file:
Generated on Tue Feb 3 14:19:43 2004 for JavaReference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001