com.jstatcom.component
Class ResultField

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JScrollPane
                  extended by com.jstatcom.component.ResultField
All Implemented Interfaces:
OutHolder, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.ScrollPaneConstants

public final class ResultField
extends javax.swing.JScrollPane
implements OutHolder

This class provides a convenient to use scrollable text field for presenting output in text form. It has a default popup menu, which can also be set to a different implementation.

All methods that change the displayed text make sure that these operations occur in the event dispatching thread. Otherwise this class is not designed to be thread-save.

Author:
Markus Kraetzig
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.BaselineResizeBehavior
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.ScrollPaneConstants
COLUMN_HEADER, HORIZONTAL_SCROLLBAR, HORIZONTAL_SCROLLBAR_ALWAYS, HORIZONTAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_NEVER, HORIZONTAL_SCROLLBAR_POLICY, LOWER_LEADING_CORNER, LOWER_LEFT_CORNER, LOWER_RIGHT_CORNER, LOWER_TRAILING_CORNER, ROW_HEADER, UPPER_LEADING_CORNER, UPPER_LEFT_CORNER, UPPER_RIGHT_CORNER, UPPER_TRAILING_CORNER, VERTICAL_SCROLLBAR, VERTICAL_SCROLLBAR_ALWAYS, VERTICAL_SCROLLBAR_AS_NEEDED, VERTICAL_SCROLLBAR_NEVER, VERTICAL_SCROLLBAR_POLICY, VIEWPORT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ResultField()
          ResultField default constructor.
 
Method Summary
 void append(java.lang.String text)
          Appends text to the text area and scrolls to the end if necessary by setting the caret position.
 void appendWithoutScroll(java.lang.String text)
          Appends text to the text area without scrolling to the end.
 void clear()
          Clears the text area from text.
 int getDefaultFontSize()
          Gets the default display font size.
 int getFontSize()
          Gets the currently displayed font size.
 int getMaxFontSize()
          Gets the maximum size for the font displaying the text.
 int getMinFontSize()
          Gets the minimum size for the font displaying the text.
 javax.swing.JPopupMenu getPopup()
          Gets the currently used RIGHT mouse JPopupMenu.
 java.lang.String getText()
          Gets the text displayed in the text area
 javax.swing.JTextArea getTextArea()
          Gets the underlying text area.
 boolean isAppendWithoutScroll()
          Whether append scrolls down or not.
 boolean isEditable()
          Gets whether editing is allowed.
 void print()
          Prints the text in the text area in a new printer thread.
 void saveToFile()
          Saves the text in this component to a file.
 void setAppendWithoutScroll(boolean appendWithoutScroll)
          Set whether append scrolls down or not.
 void setEditable(boolean newEditable)
          Sets whether editing is allowed.
 void setFontSize(int newFontSize)
          Sets the currently displayed font size.
 void setPopup(javax.swing.JPopupMenu newRfPopup)
          Sets a new popup whose processMouseEvent method is called, when a mouseReleased event occured.
 void setText(java.lang.String text)
          Sets text to the text area.
 
Methods inherited from class javax.swing.JScrollPane
createHorizontalScrollBar, createVerticalScrollBar, getAccessibleContext, getColumnHeader, getCorner, getHorizontalScrollBar, getHorizontalScrollBarPolicy, getRowHeader, getUI, getUIClassID, getVerticalScrollBar, getVerticalScrollBarPolicy, getViewport, getViewportBorder, getViewportBorderBounds, isValidateRoot, isWheelScrollingEnabled, setColumnHeader, setColumnHeaderView, setComponentOrientation, setCorner, setHorizontalScrollBar, setHorizontalScrollBarPolicy, setLayout, setRowHeader, setRowHeaderView, setUI, setVerticalScrollBar, setVerticalScrollBarPolicy, setViewport, setViewportBorder, setViewportView, setWheelScrollingEnabled, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResultField

public ResultField()
ResultField default constructor.

Method Detail

append

public void append(java.lang.String text)
Appends text to the text area and scrolls to the end if necessary by setting the caret position. This happens always within the EventDispatchingThread.

Specified by:
append in interface OutHolder
Parameters:
text - the string to append to the text

appendWithoutScroll

public void appendWithoutScroll(java.lang.String text)
Appends text to the text area without scrolling to the end. This happens always within the EventDispatchingThread.

Parameters:
text - the string to append to the text

clear

public void clear()
Clears the text area from text. This happens always within the EventDispatchingThread.

Specified by:
clear in interface OutHolder

getDefaultFontSize

public int getDefaultFontSize()
Gets the default display font size.

Returns:
the default font size

getFontSize

public int getFontSize()
Gets the currently displayed font size.

Returns:
the font size

getMaxFontSize

public int getMaxFontSize()
Gets the maximum size for the font displaying the text.

Returns:
maximum size

getMinFontSize

public int getMinFontSize()
Gets the minimum size for the font displaying the text.

Returns:
minimum size

getPopup

public javax.swing.JPopupMenu getPopup()
Gets the currently used RIGHT mouse JPopupMenu.

Returns:
the currently used RIGHT mouse popup

getText

public java.lang.String getText()
Gets the text displayed in the text area

Returns:
the displayed text

getTextArea

public javax.swing.JTextArea getTextArea()
Gets the underlying text area.

Returns:
the text area of this ResultField

isEditable

public boolean isEditable()
Gets whether editing is allowed.

Returns:
true if editable

print

public void print()
Prints the text in the text area in a new printer thread.


saveToFile

public void saveToFile()
Saves the text in this component to a file. First ask to select the file to write to.


setEditable

public void setEditable(boolean newEditable)
Sets whether editing is allowed. This happens always within the EventDispatchingThread.

Parameters:
newEditable - true if editable

setFontSize

public void setFontSize(int newFontSize)
Sets the currently displayed font size. This happens always within the EventDispatchingThread.

Parameters:
newFontSize - the font size

setPopup

public void setPopup(javax.swing.JPopupMenu newRfPopup)
Sets a new popup whose processMouseEvent method is called, when a mouseReleased event occured.

Parameters:
newRfPopup - if null then it is just removed

setText

public void setText(java.lang.String text)
Sets text to the text area. This happens always within the EventDispatchingThread.

Parameters:
text - the string to set as text

isAppendWithoutScroll

public boolean isAppendWithoutScroll()
Whether append scrolls down or not.

Returns:

setAppendWithoutScroll

public void setAppendWithoutScroll(boolean appendWithoutScroll)
Set whether append scrolls down or not.

Parameters:
appendWithoutScroll - if true do not scroll, default is false (do scroll down)