Class JLabeledTextField

  • All Implemented Interfaces:
    java.awt.MenuContainer , java.awt.event.FocusListener , java.awt.image.ImageObserver , java.io.Serializable , java.util.EventListener , javax.accessibility.Accessible , javax.swing.TransferHandler.HasGetTransferHandler , org.apache.jorphan.gui.JLabeledField

    
    public class JLabeledTextField
    extends JPanel implements JLabeledField, FocusListener
                        

    A Helper component that wraps a JTextField with a label into a JPanel (this). This component also has an efficient event handling mechanism for handling the text changing in the Text Field. The registered change listeners are only called when the text has changed.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      List<JComponent> getComponentList() Get the label JLabel followed by the text field @link JTextField.
      void setEnabled(boolean enable)
      void focusLost(FocusEvent pFocusEvent) Callback method when the focus to the Text Field component is lost.
      void focusGained(FocusEvent pFocusEvent) Catch what the value was when focus was gained.
      void setLabel(String pLabel) Set the text displayed in the label.
      void setText(String pText) Set the text displayed in the Text Field.
      String getText() Returns the text in the Text Field.
      String getLabel() Returns the text of the label.
      void setToolTipText(String text) Registers the text to display in a tool tip.
      String getToolTipText() Returns the tooltip string that has been set with setToolTipText
      void addChangeListener(ChangeListener pChangeListener) Adds a change listener, that will be notified when the text in the text field is changed.
      void removeChangeListener(ChangeListener pChangeListener) Removes a change listener.
      boolean requestFocusInWindow()
      • Methods inherited from class javax.swing.JPanel

        getAccessibleContext, getUI, getUIClassID, setUI, updateUI
      • Methods inherited from class javax.swing.JComponent

        addAncestorListener, addNotify, addVetoableChangeListener, contains, createToolTip, disable, enable, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputVerifier, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getTopLevelAncestor, getTransferHandler, getUI, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, requestDefaultFocus, requestFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
      • Methods inherited from class java.awt.Container

        add, add, addContainerListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, getComponent, getComponentAt, getComponentCount, getComponentZOrder, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate
      • Methods inherited from class java.awt.Component

        action, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, createImage, createVolatileImage, dispatchEvent, enableInputMethods, getBackground, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusOwner, isFocusTraversable, isFocusable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, resize, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusTraversalKeysEnabled, setFocusable, setIgnoreRepaint, setLocale, setLocation, setMixingCutoutShape, setName, setSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JLabeledTextField

        JLabeledTextField()
        Default constructor, The label and the Text field are left empty.
      • JLabeledTextField

        JLabeledTextField(String pLabel)
        Constructs a new component with the label displaying the passed text.
        Parameters:
        pLabel - The text to in the label.
      • JLabeledTextField

        JLabeledTextField(String pLabel, int size)
        Constructs a new component with the label displaying the passed text.
        Parameters:
        pLabel - The text to in the label.
        size - size of text field
      • JLabeledTextField

        JLabeledTextField(String pLabel, Color bk)
        Size defaults to 20
        Parameters:
        pLabel - The text to in the label.
        bk - Color background color
      • JLabeledTextField

        JLabeledTextField(String pLabel, int size, Color bk, boolean editable)
        Size defaults to 20
        Parameters:
        pLabel - The text to in the label.
        size - textfield length
        bk - Color background color may be null
        editable - boolean
    • Method Detail

      • focusLost

         void focusLost(FocusEvent pFocusEvent)

        Callback method when the focus to the Text Field component is lost.

        Parameters:
        pFocusEvent - The focus event that occurred.
      • setLabel

         void setLabel(String pLabel)

        Set the text displayed in the label.

        Parameters:
        pLabel - The new label text.
      • setText

         void setText(String pText)

        Set the text displayed in the Text Field.

        Parameters:
        pText - The new text to display in the text field.
      • getText

         String getText()

        Returns the text in the Text Field.

        Returns:

        The text in the Text Field.

      • getLabel

         String getLabel()

        Returns the text of the label.

        Returns:

        The text of the label.

      • setToolTipText

         void setToolTipText(String text)

        Registers the text to display in a tool tip. The text displays when the cursor lingers over the component.

        Parameters:
        text - the string to display; if the text is null, the tool tip is turned off for this component
      • getToolTipText

         String getToolTipText()

        Returns the tooltip string that has been set with setToolTipText

        Returns:

        the text of the tool tip

      • addChangeListener

         void addChangeListener(ChangeListener pChangeListener)

        Adds a change listener, that will be notified when the text in the text field is changed. The ChangeEvent that will be passed to registered listeners will contain this object as the source, allowing the new text to be extracted using the getText method.

        Parameters:
        pChangeListener - The listener to add