com.deltax.util
Class JPanelOutputStream

java.lang.Object
  extended byjava.io.OutputStream
      extended bycom.deltax.util.JPanelOutputStream

public class JPanelOutputStream
extends java.io.OutputStream

A class to use a JPanel as an output stream.

The class extends OutputStream and outputs to a JPanel, which can be obtained by invoking getPanel().

The flush() method can be called to actually update the associated panel.

Version:
1.2

Field Summary
protected  java.lang.String lineSep
          The platform line separator
protected  javax.swing.JList list
          The JList used to display the output.
protected  int maxLines
          The number of maximum allowed lines, or -1.
protected  javax.swing.JPanel panel
          The associated JPanel object.
protected  java.lang.StringBuffer sb
          The current line buffer.
 
Constructor Summary
JPanelOutputStream()
          Create JPanelOutputStream.
JPanelOutputStream(int maxLines)
          Create JPanelOutputStream whose JPanel will display the given maximum number of lines.
JPanelOutputStream(java.lang.String[] data)
          Create a panel which displays the given lines.
 
Method Summary
 void clear()
          Clear the panel
 void flush()
          Completes the current line by writing a line separator.
 java.lang.String getContents()
          Return the panel contents as a String.
 java.awt.Font getFont()
          Get the font with which the panel displays the text.
 javax.swing.JPanel getPanel()
          Return the panel associated to the panel.
 void setFont(java.awt.Font font)
          Set the font with which the panel displays the text.
 void write(int b)
          Implements the OutputStream's write method.
 
Methods inherited from class java.io.OutputStream
close, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

maxLines

protected int maxLines
The number of maximum allowed lines, or -1.


panel

protected javax.swing.JPanel panel
The associated JPanel object.


list

protected javax.swing.JList list
The JList used to display the output.


sb

protected java.lang.StringBuffer sb
The current line buffer.


lineSep

protected java.lang.String lineSep
The platform line separator

Constructor Detail

JPanelOutputStream

public JPanelOutputStream()
Create JPanelOutputStream.


JPanelOutputStream

public JPanelOutputStream(int maxLines)
Create JPanelOutputStream whose JPanel will display the given maximum number of lines.

Parameters:
maxLines - tha maximum number of lines of the associated JPanel.

JPanelOutputStream

public JPanelOutputStream(java.lang.String[] data)
Create a panel which displays the given lines.

Parameters:
data - an array of lines
Method Detail

setFont

public void setFont(java.awt.Font font)
Set the font with which the panel displays the text.

Parameters:
font - the font to use

getFont

public java.awt.Font getFont()
Get the font with which the panel displays the text.


clear

public void clear()
Clear the panel


getContents

public java.lang.String getContents()
Return the panel contents as a String. The platform default line separator is used to divide the lines.

Returns:
the panel contents as a String

getPanel

public javax.swing.JPanel getPanel()
Return the panel associated to the panel.


write

public void write(int b)
           throws java.io.IOException
Implements the OutputStream's write method.

Parameters:
b - the character to write
Throws:
java.io.IOException

flush

public void flush()
Completes the current line by writing a line separator.