com.jbbres.lib.actions.tools.swing
Class JVTextField

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.text.JTextComponent
                  extended by javax.swing.JTextField
                      extended by com.jbbres.lib.actions.tools.swing.JVTextField
All Implemented Interfaces:
com.jbbres.lib.PropertiesOwner, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.Scrollable, javax.swing.SwingConstants

public class JVTextField
extends javax.swing.JTextField
implements com.jbbres.lib.PropertiesOwner

A text field that can also receive Variables as content.

Variables should be inputed between %. For example, if you want to use the content of a variable nammed MyVar, you need to input the text as follow: %MyVar%.

When calling the getText method, the variable are replaced by their value (equivalent to calling myVariable.getValue().toString()). If the value is null, the variable is replaced by an empty String. If no variable with the given name exists, the text is not changed.

If you want to access to the text without replacement, call getLogicalText().

Since:
1.0.0
Version:
1.0.0
Author:
Jean-Baptiste Bres
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.text.JTextComponent
javax.swing.text.JTextComponent.AccessibleJTextComponent, javax.swing.text.JTextComponent.DropLocation, javax.swing.text.JTextComponent.KeyBinding
 
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
static java.lang.String PROPERTY_CONTENT
          The property associated to the content of the text field.
 
Fields inherited from class javax.swing.JTextField
notifyAction
 
Fields inherited from class javax.swing.text.JTextComponent
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY
 
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.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JVTextField()
          Constructs a new TextField.
JVTextField(javax.swing.text.Document doc, java.lang.String text, int columns)
          Constructs a new JTextField that uses the given text storage model and the given number of columns.
JVTextField(int columns)
          Constructs a new empty TextField with the specified number of columns.
JVTextField(java.lang.String text)
          Constructs a new TextField initialized with the specified text.
JVTextField(java.lang.String text, int columns)
          Constructs a new TextField initialized with the specified text and columns.
JVTextField(Workflow workflow)
          Constructs a new TextField.
JVTextField(Workflow workflow, javax.swing.text.Document doc, java.lang.String text, int columns)
          Constructs a new JTextField that uses the given text storage model and the given number of columns.
JVTextField(Workflow workflow, int columns)
          Constructs a new empty TextField with the specified number of columns.
JVTextField(Workflow workflow, java.lang.String text)
          Constructs a new TextField initialized with the specified text.
JVTextField(Workflow workflow, java.lang.String text, int columns)
          Constructs a new TextField initialized with the specified text and columns.
 
Method Summary
 java.lang.String getLogicalSelectedText()
          Returns the text contained in this TextComponent, coded with variable values.
 java.lang.String getLogicalText()
          Returns the text contained in this TextComponent, coded with variable values.
 java.util.Properties getProperties()
          Returns the properties describing the current status of the JTextField.
 java.lang.String getSelectedText()
           
 java.lang.String getText()
           
 java.lang.String getText(int offs, int len)
           
 Workflow getWorkflow()
          Returns the workflow.
 void setProperties(java.util.Properties properties)
          Sets the JTextField with the given properties.
 void setWorkflow(Workflow workflow)
          Set the workflow associated to the JVariableTextField.
 
Methods inherited from class javax.swing.JTextField
addActionListener, getAccessibleContext, getAction, getActionListeners, getActions, getColumns, getHorizontalAlignment, getHorizontalVisibility, getPreferredSize, getScrollOffset, getUIClassID, isValidateRoot, postActionEvent, removeActionListener, scrollRectToVisible, setAction, setActionCommand, setColumns, setDocument, setFont, setHorizontalAlignment, setScrollOffset
 
Methods inherited from class javax.swing.text.JTextComponent
addCaretListener, addInputMethodListener, addKeymap, copy, cut, getCaret, getCaretColor, getCaretListeners, getCaretPosition, getDisabledTextColor, getDocument, getDragEnabled, getDropLocation, getDropMode, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getNavigationFilter, getPreferredScrollableViewportSize, getPrintable, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getToolTipText, getUI, isEditable, loadKeymap, modelToView, moveCaretPosition, paste, print, print, print, read, removeCaretListener, removeKeymap, removeNotify, replaceSelection, select, selectAll, setCaret, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDragEnabled, setDropMode, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setText, setUI, updateUI, viewToModel, write
 
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, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, 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, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, 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, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, 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, 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
 

Field Detail

PROPERTY_CONTENT

public static final java.lang.String PROPERTY_CONTENT
The property associated to the content of the text field.

See Also:
Constant Field Values
Constructor Detail

JVTextField

public JVTextField(Workflow workflow)
Constructs a new TextField.

Parameters:
workflow - - the workflow associated to the object

JVTextField

public JVTextField(Workflow workflow,
                   javax.swing.text.Document doc,
                   java.lang.String text,
                   int columns)
Constructs a new JTextField that uses the given text storage model and the given number of columns.

Parameters:
workflow - - the workflow associated to the object
doc - - the text storage to use; if this is null, a default will be provided by calling the createDefaultModel method
text - - the initial string to display, or null
columns - - the number of columns to use to calculate the preferred width >= 0; if columns is set to zero, the preferred width will be whatever naturally results from the component implementation

JVTextField

public JVTextField(Workflow workflow,
                   int columns)
Constructs a new empty TextField with the specified number of columns.

Parameters:
workflow - - the workflow associated to the object
columns - - the number of columns to use to calculate the preferred width >= 0; if columns is set to zero, the preferred width will be whatever naturally results from the component implementation

JVTextField

public JVTextField(Workflow workflow,
                   java.lang.String text,
                   int columns)
Constructs a new TextField initialized with the specified text and columns.

Parameters:
workflow - - the workflow associated to the object
text - - the initial string to display, or null
columns - - the number of columns to use to calculate the preferred width >= 0; if columns is set to zero, the preferred width will be whatever naturally results from the component implementation

JVTextField

public JVTextField(Workflow workflow,
                   java.lang.String text)
Constructs a new TextField initialized with the specified text.

Parameters:
workflow - - the workflow associated to the object
text - - the initial string to display, or null

JVTextField

public JVTextField()
Constructs a new TextField.

Using this constructor is not recommanded. You should prefer use JVariableTextField(Workflow) as the associated workflow required to be defined in order to work properly. If you do not know the workflow, does not forget to call the setWorkflow(Workflow) method once you will know it.


JVTextField

public JVTextField(javax.swing.text.Document doc,
                   java.lang.String text,
                   int columns)
Constructs a new JTextField that uses the given text storage model and the given number of columns.

Using this constructor is not recommanded. You should prefer use JVariableTextField(Workflow, Document, String, int) as the associated workflow required to be defined in order to work properly. If you do not know the workflow, does not forget to call the setWorkflow(Workflow) method once you will know it.

Parameters:
doc - - the text storage to use; if this is null, a default will be provided by calling the createDefaultModel method
text - - the initial string to display, or null
columns - - the number of columns to use to calculate the preferred width >= 0; if columns is set to zero, the preferred width will be whatever naturally results from the component implementation

JVTextField

public JVTextField(int columns)
Constructs a new empty TextField with the specified number of columns.

Using this constructor is not recommanded. You should prefer use JVariableTextField(Workflow, int) as the associated workflow required to be defined in order to work properly. If you do not know the workflow, does not forget to call the setWorkflow(Workflow) method once you will know it.

Parameters:
columns - - the number of columns to use to calculate the preferred width >= 0; if columns is set to zero, the preferred width will be whatever naturally results from the component implementation

JVTextField

public JVTextField(java.lang.String text,
                   int columns)
Constructs a new TextField initialized with the specified text and columns.

Using this constructor is not recommanded. You should prefer use JVariableTextField(Workflow, String, int) as the associated workflow required to be defined in order to work properly. If you do not know the workflow, does not forget to call the setWorkflow(Workflow) method once you will know it.

Parameters:
text - - the initial string to display, or null
columns - - the number of columns to use to calculate the preferred width >= 0; if columns is set to zero, the preferred width will be whatever naturally results from the component implementation

JVTextField

public JVTextField(java.lang.String text)
Constructs a new TextField initialized with the specified text.

Using this constructor is not recommanded. You should prefer use JVariableTextField(Workflow, String) as the associated workflow required to be defined in order to work properly. If you do not know the workflow, does not forget to call the setWorkflow(Workflow) method once you will know it.

Parameters:
text - - the initial string to display, or null
Method Detail

getText

public java.lang.String getText()
Overrides:
getText in class javax.swing.text.JTextComponent

getLogicalText

public java.lang.String getLogicalText()
Returns the text contained in this TextComponent, coded with variable values. If the underlying document is null, will give a NullPointerException. Note that text is not a bound property, so no PropertyChangeEvent is fired when it changes. To listen for changes to the text, use DocumentListener.

Returns:
the text contained in this TextComponent, coded with variable values.

getLogicalSelectedText

public java.lang.String getLogicalSelectedText()
Returns the text contained in this TextComponent, coded with variable values. If the selection is null or the document empty, returns null.

Returns:
the text contained in this TextComponent, coded with variable values.

getSelectedText

public java.lang.String getSelectedText()
Overrides:
getSelectedText in class javax.swing.text.JTextComponent

getText

public java.lang.String getText(int offs,
                                int len)
                         throws javax.swing.text.BadLocationException
Overrides:
getText in class javax.swing.text.JTextComponent
Throws:
javax.swing.text.BadLocationException

setWorkflow

public void setWorkflow(Workflow workflow)
Set the workflow associated to the JVariableTextField. The workflow is used to iddentify and link to Variables

Parameters:
workflow - - the workflow

getWorkflow

public Workflow getWorkflow()
Returns the workflow.

Returns:
the workflow

getProperties

public java.util.Properties getProperties()
Returns the properties describing the current status of the JTextField.

Specified by:
getProperties in interface com.jbbres.lib.PropertiesOwner
Returns:
the properties describing the current status of the JTextField.

setProperties

public void setProperties(java.util.Properties properties)
Sets the JTextField with the given properties.

Specified by:
setProperties in interface com.jbbres.lib.PropertiesOwner
Parameters:
properties - - properties


To file bugs or suggest feature enhancements, visit the app.jbbres.com Bug Reporter website.

Additional documentation available online at http://app.jbbres.com/actions/developers.

Copyright � 2009-2011 app.jbbres.com. All Rights Reserved.