org.gjt.btools.gui.component
Class TextDisplayRegion

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--org.gjt.btools.gui.component.TextDisplayRegion
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class TextDisplayRegion
extends javax.swing.JComponent

Component that display many lines of text against an empty background. The text is left justified and displayed using SansSerif, 12pt. Lines of text can be inserted using the insertLine(), insertLineStrip() and insertMessage() methods and can be removed using removeAllLines().

This component is used by the MessageBox class amongst other things.

See Also:
MessageBox, Serialized Form

Field Summary
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Container
 
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
TextDisplayRegion()
          Create a new text display region.
 
Method Summary
 void completeRefresh()
          Performs any revalidation and repainting required when the contents of this region change.
 java.awt.Dimension getMinimumSize()
          Returns the minimum size for this component to occupy.
 java.awt.Dimension getPreferredSize()
          Returns the preferred size for this component to occupy.
 void insertLine(java.lang.String line)
          Inserts a line of text into the display region.
 void insertLineStrip(java.lang.String line)
          Inserts a line of text into the display region, first stripping all trailing spaces.
 void insertMessage(java.lang.String msg, int maxLineLength)
          Inserts the given message into the text display region, splitting the message across several lines to ensure that no line is too long.
 void paint(java.awt.Graphics g)
          Called whenever the TextDisplayRegion is to be painted.
 void removeAllLines()
          Removes all lines of text from the display region.
 void setPads(int hPad, int vPad)
          Sets the padding in pixels between the text and the edge of the component.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TextDisplayRegion

public TextDisplayRegion()
Create a new text display region.

Method Detail

getMinimumSize

public java.awt.Dimension getMinimumSize()
Returns the minimum size for this component to occupy.

Overrides:
getMinimumSize in class javax.swing.JComponent
Returns:
the component's minimum size.

getPreferredSize

public java.awt.Dimension getPreferredSize()
Returns the preferred size for this component to occupy.

Overrides:
getPreferredSize in class javax.swing.JComponent
Returns:
the component's preferred size.

removeAllLines

public void removeAllLines()
Removes all lines of text from the display region.

If the component is visible or already belongs to a container, completeRefresh() will need to be called after this routine.


insertLine

public void insertLine(java.lang.String line)
Inserts a line of text into the display region. This line will be placed after all existing lines.

If the component is visible or already belongs to a container, completeRefresh() will need to be called after this routine.

The method insertLineStrip() performs the same function as insertLine(), but first strips all trailing spaces from the line of text.

Parameters:
line - the line of text to be inserted.
See Also:
insertLineStrip(java.lang.String)

insertLineStrip

public void insertLineStrip(java.lang.String line)
Inserts a line of text into the display region, first stripping all trailing spaces. This line will be placed after all existing lines.

If the component is visible or already belongs to a container, completeRefresh() will need to be called after this routine.

If the string is known to have no trailing spaces, insertLine() should be used instead.

Parameters:
line - the line of text to be inserted.
See Also:
insertLine(java.lang.String)

insertMessage

public void insertMessage(java.lang.String msg,
                          int maxLineLength)
Inserts the given message into the text display region, splitting the message across several lines to ensure that no line is too long. The message is inserted below any lines that might already be there.

If the component is visible or already belongs to a container, completeRefresh() will need to be called after this routine.

Parameters:
msg - the message to be inserted.
maxLineLength - the maximum number of characters to place on a single line.

paint

public void paint(java.awt.Graphics g)
Called whenever the TextDisplayRegion is to be painted.

Overrides:
paint in class javax.swing.JComponent
Parameters:
g - the graphics object through which to paint.

setPads

public void setPads(int hPad,
                    int vPad)
Sets the padding in pixels between the text and the edge of the component. Default values are zero in each direction.

Parameters:
hPad - horizontal padding.
vPad - vertical padding.

completeRefresh

public void completeRefresh()
Performs any revalidation and repainting required when the contents of this region change. This routine should be called if the contents change whilst this region is already visible or belongs to a container.

The current implementation is simply to call revalidate() and repaint().



Copyright © 1998-2001, Ben Burton
This software is released under the GNU Public License.
For further information, or to submit a bug or other problem, please contact Ben Burton (bab@debian.org).