de.jaetzold.util
Class TextOutput

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--de.jaetzold.util.TextOutput
All Implemented Interfaces:
Accessible, CommandLine, ImageObserver, MenuContainer, Serializable

public class TextOutput
extends Panel
implements CommandLine

TextOutput should be an interface later. For now it is everything what deals with user-interaction, also the Input. The Interface "TextOutput" should provide the ability to: "append" Strings; "clear" the output, or "set" it to ""; maybe: "get" everything which is shown at the moment;

See Also:
Serialized Form

Inner classes inherited from class java.awt.Panel
Panel.AccessibleAWTPanel
 
Inner classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
Component.AccessibleAWTComponent
 
Field Summary
protected  StringBuffer content
          This is our own buffer of the output.
protected static int FONTSIZE
          It is the size of all fonts.
protected  int histindex
          Thats where we are when we scroll through our history.
protected static int HISTLENGTH
          Maximum number of Command Strings in the History.
protected  String[] history
          The Array where the Commands for the history are stored.
protected static boolean HISTSQUEEZE
          If this is true, successive equal Commands are only stored once.
protected  int histtop
          The last index in History which contains a Command.
protected  TextField input
          This is where we get the Input-Events/Commands from.
protected  TextArea output
          Main output.
protected  Label prompt
          This is where we present the prompt.
protected static int PROMPTLENGTH
          Every prompt longer than PROMPTLENGTH will be cut on the left side.
protected static int SCROLLBACKMAX
          The Buffer is truncated to SCROLLBACKMIN if it exeeds SCROLLBACKMAX.
protected static int SCROLLBACKMIN
          A greater difference between min and max increases the time to the next call of setText() to the TextArea which always results in some flickering.
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TextOutput(int rows, int cols)
          Constructs a new TextOutput whith default parameters.
 
Method Summary
 void addCommandLineListener(CommandLineListener l)
          This sets the CommandLineListener.
 void append(Object obj)
          In Windows95 the TextArea cant contain an unlimited amount of text, so I try to limit it somehow.
 String getPrompt()
           
 void setPrompt(String str)
          Set str as prompt.
 
Methods inherited from class java.awt.Panel
addNotify, getAccessibleContext
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, setLayout, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

output

protected TextArea output
Main output.

input

protected TextField input
This is where we get the Input-Events/Commands from.

prompt

protected Label prompt
This is where we present the prompt.

content

protected StringBuffer content
This is our own buffer of the output. In Windows95 the TextArea cant contain an unlimited amount of text, so I try to limit it somehow.

history

protected String[] history
The Array where the Commands for the history are stored. It has HISTLENGTH elements.

histindex

protected int histindex
Thats where we are when we scroll through our history.

histtop

protected int histtop
The last index in History which contains a Command. This Command has not been send to our listener yet.

FONTSIZE

protected static final int FONTSIZE
It is the size of all fonts.

PROMPTLENGTH

protected static final int PROMPTLENGTH
Every prompt longer than PROMPTLENGTH will be cut on the left side.

SCROLLBACKMAX

protected static final int SCROLLBACKMAX
The Buffer is truncated to SCROLLBACKMIN if it exeeds SCROLLBACKMAX.

SCROLLBACKMIN

protected static final int SCROLLBACKMIN
A greater difference between min and max increases the time to the next call of setText() to the TextArea which always results in some flickering.

HISTLENGTH

protected static final int HISTLENGTH
Maximum number of Command Strings in the History.

HISTSQUEEZE

protected static final boolean HISTSQUEEZE
If this is true, successive equal Commands are only stored once.
Constructor Detail

TextOutput

public TextOutput(int rows,
                  int cols)
Constructs a new TextOutput whith default parameters. The output-aerea will have 30 lines & 80 columns. The Font is "Monospaced". The Windowtitle is set to the given parameter.
Method Detail

append

public void append(Object obj)
In Windows95 the TextArea cant contain an unlimited amount of text, so I try to limit it somehow.

setPrompt

public void setPrompt(String str)
Set str as prompt. The prompt will only be set to the string after the last occurence of any newline-character.
Specified by:
setPrompt in interface CommandLine

getPrompt

public String getPrompt()
Specified by:
getPrompt in interface CommandLine

addCommandLineListener

public void addCommandLineListener(CommandLineListener l)
This sets the CommandLineListener. Though this method means "add", DON'T call it twice, I don't know what will happen. It registrates Action- and Key-listeners for our input-TextField which do the stuff with the history.
Specified by:
addCommandLineListener in interface CommandLine