com.jstatcom.component
Class ResultField
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JScrollPane
-
- 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.
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
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
-
-
Constructor Summary
Constructors Constructor and Description ResultField()ResultFielddefault constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidappend(java.lang.String text)Appendstextto the text area and scrolls to the end if necessary by setting the caret position.voidappendWithoutScroll(java.lang.String text)Appendstextto the text area without scrolling to the end.voidclear()Clears the text area from text.intgetDefaultFontSize()Gets the default display font size.intgetFontSize()Gets the currently displayed font size.intgetMaxFontSize()Gets the maximum size for the font displaying the text.intgetMinFontSize()Gets the minimum size for the font displaying the text.javax.swing.JPopupMenugetPopup()Gets the currently used RIGHT mouseJPopupMenu.java.lang.StringgetText()Gets the text displayed in the text areajavax.swing.JTextAreagetTextArea()Gets the underlying text area.booleanisAppendWithoutScroll()Whetherappendscrolls down or not.booleanisEditable()Gets whether editing is allowed.voidprint()Prints the text in the text area in a new printer thread.voidsaveToFile()Saves the text in this component to a file.voidsetAppendWithoutScroll(boolean appendWithoutScroll)Set whetherappendscrolls down or not.voidsetEditable(boolean newEditable)Sets whether editing is allowed.voidsetFontSize(int newFontSize)Sets the currently displayed font size.voidsetPopup(javax.swing.JPopupMenu newRfPopup)Sets a new popup whoseprocessMouseEventmethod is called, when amouseReleasedevent occured.voidsetText(java.lang.String text)Setstextto 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, hide, 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, 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, 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, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Method Detail
-
append
public void append(java.lang.String text)
Appendstextto the text area and scrolls to the end if necessary by setting the caret position. This happens always within theEventDispatchingThread.
-
appendWithoutScroll
public void appendWithoutScroll(java.lang.String text)
Appendstextto the text area without scrolling to the end. This happens always within theEventDispatchingThread.- Parameters:
text- the string to append to the text
-
clear
public void clear()
Clears the text area from text. This happens always within theEventDispatchingThread.
-
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 mouseJPopupMenu.- 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:
trueif 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 theEventDispatchingThread.- Parameters:
newEditable-trueif editable
-
setFontSize
public void setFontSize(int newFontSize)
Sets the currently displayed font size. This happens always within theEventDispatchingThread.- Parameters:
newFontSize- the font size
-
setPopup
public void setPopup(javax.swing.JPopupMenu newRfPopup)
Sets a new popup whoseprocessMouseEventmethod is called, when amouseReleasedevent occured.- Parameters:
newRfPopup- ifnullthen it is just removed
-
setText
public void setText(java.lang.String text)
Setstextto the text area. This happens always within theEventDispatchingThread.- Parameters:
text- the string to set as text
-
isAppendWithoutScroll
public boolean isAppendWithoutScroll()
Whetherappendscrolls down or not.- Returns:
-
setAppendWithoutScroll
public void setAppendWithoutScroll(boolean appendWithoutScroll)
Set whetherappendscrolls down or not.- Parameters:
appendWithoutScroll- iftruedo not scroll, default isfalse(do scroll down)
-
-
DMelt 3.0 © DataMelt by jWork.ORG