Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

javax.swing
Class JTextField  view JTextField download JTextField.java

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.text.JTextComponent
                  extended byjavax.swing.JTextField
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, Scrollable, java.io.Serializable, SwingConstants
Direct Known Subclasses:
JFormattedTextField, JPasswordField, JTable.TableTextField

public class JTextField
extends javax.swing.text.JTextComponent
implements SwingConstants


Nested Class Summary
protected  class JTextField.AccessibleJTextField
          AccessibleJTextField
 
Nested classes inherited from class javax.swing.text.JTextComponent
javax.swing.text.JTextComponent.AccessibleJTextComponent, javax.swing.text.JTextComponent.KeyBinding
 
Nested classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private  Action action
           
private  java.lang.String actionCommand
           
private  java.beans.PropertyChangeListener actionPropertyChangeListener
           
private static Action[] actions
           
private  int align
           
private  int columns
           
private  BoundedRangeModel horizontalVisibility
          The horizontal visibility of the textfield.
static java.lang.String notifyAction
          Name of the action that gets sent when the content of the text field gets accepted.
private static long serialVersionUID
           
 
Fields inherited from class javax.swing.text.JTextComponent
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY
 
Fields inherited from class javax.swing.JComponent
accessibleContext, alignmentX, alignmentY, autoscrolls, border, debugGraphicsOptions, doubleBuffered, isCompletelyDirty, isPaintingDoubleBuffered, listenerList, maximumSize, minimumSize, opaque, preferredSize, requestFocusEnabled, TOOL_TIP_TEXT_KEY, toolTipText, 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 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
JTextField()
          Creates a new instance of JTextField.
JTextField(javax.swing.text.Document doc, java.lang.String text, int columns)
          Creates a new instance of JTextField.
JTextField(int columns)
          Creates a new instance of JTextField.
JTextField(java.lang.String text)
          Creates a new instance of JTextField.
JTextField(java.lang.String text, int columns)
          Creates a new instance of JTextField.
 
Method Summary
 void addActionListener(java.awt.event.ActionListener listener)
          Adds a new listener object to this text field.
protected  void configurePropertiesFromAction(Action action)
           
protected  java.beans.PropertyChangeListener createActionPropertyChangeListener(Action action)
           
protected  javax.swing.text.Document createDefaultModel()
          Creates the default model for this text field.
protected  void fireActionPerformed()
          Sends an action event to all registered ActionListener objects.
 javax.accessibility.AccessibleContext getAccessibleContext()
          Returns the accessible context associated with the JTextField.
 Action getAction()
           
 java.awt.event.ActionListener[] getActionListeners()
          Returns all registered ActionListener objects.
 Action[] getActions()
          Returns the set of Actions that are commands for the editor.
 int getColumns()
          Returns the number of columns of this text field.
protected  int getColumnWidth()
          Returns the column width, which is the width of the character m for the font in use.
 int getHorizontalAlignment()
          Returns the horizontal alignment, which is one of: JTextField.LEFT, JTextField.CENTER, JTextField.RIGHT, JTextField.LEADING, JTextField.TRAILING.
 BoundedRangeModel getHorizontalVisibility()
          Returns the bounded range model that describes the horizontal visibility of the text field in the case when the text does not fit into the available space.
 java.awt.Dimension getPreferredSize()
          Returns the preferred size.
 int getScrollOffset()
          Returns the scroll offset in pixels.
 java.lang.String getUIClassID()
          Returns the class ID for the UI.
 boolean isValidateRoot()
          Returns true, unless this is embedded in a JViewport in which case the viewport takes responsibility of validating.
 void postActionEvent()
           
 void removeActionListener(java.awt.event.ActionListener listener)
          Removes a listener object from this text field.
 void scrollRectToVisible(java.awt.Rectangle r)
          Calls scrollRectToVisible on the component's parent.
 void setAction(Action newAction)
           
 void setActionCommand(java.lang.String command)
          Sets the command string used in action events.
 void setColumns(int columns)
          Sets the number of columns and then invalidates the layout.
 void setDocument(javax.swing.text.Document doc)
          Sets the document to be used for this JTextField.
 void setFont(java.awt.Font newFont)
          Sets the current font and revalidates so the font will take effect.
 void setHorizontalAlignment(int newAlign)
          Sets the horizontal alignment of the text.
 void setScrollOffset(int offset)
          Sets the scroll offset in pixels.
 
Methods inherited from class javax.swing.text.JTextComponent
addCaretListener, addInputMethodListener, addKeymap, copy, cut, fireCaretUpdate, getCaret, getCaretColor, getCaretListeners, getCaretPosition, getDisabledTextColor, getDocument, getDragEnabled, getFocusAccelerator, getHighlighter, getInputMethodListeners, getKeymap, getKeymap, getMargin, getNavigationFilter, getPreferredScrollableViewportSize, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getText, getToolTipText, getUI, isEditable, loadKeymap, modelToView, moveCaretPosition, paramString, paste, read, removeCaretListener, removeInputMethodListener, removeKeymap, replaceSelection, select, selectAll, setCaret, setCaretColor, setCaretPosition, setDisabledTextColor, setDragEnabled, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setText, setUI, updateUI, viewToModel, write
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, fireAncestorEvent, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paintImmediately2, paintSimple, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setUIProperty, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateComponentInputMap
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, 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, 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, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

actions

private static final Action[] actions

notifyAction

public static final java.lang.String notifyAction
Name of the action that gets sent when the content of the text field gets accepted.

See Also:
Constant Field Values

columns

private int columns

align

private int align

action

private Action action
Since:
1.3

actionCommand

private java.lang.String actionCommand
Since:
1.3

actionPropertyChangeListener

private java.beans.PropertyChangeListener actionPropertyChangeListener

horizontalVisibility

private BoundedRangeModel horizontalVisibility
The horizontal visibility of the textfield.

Constructor Detail

JTextField

public JTextField()
Creates a new instance of JTextField.


JTextField

public JTextField(java.lang.String text)
Creates a new instance of JTextField.


JTextField

public JTextField(int columns)
Creates a new instance of JTextField.


JTextField

public JTextField(java.lang.String text,
                  int columns)
Creates a new instance of JTextField.


JTextField

public JTextField(javax.swing.text.Document doc,
                  java.lang.String text,
                  int columns)
Creates a new instance of JTextField.

Method Detail

createDefaultModel

protected javax.swing.text.Document createDefaultModel()
Creates the default model for this text field. This implementation returns an instance of PlainDocument.


setDocument

public void setDocument(javax.swing.text.Document doc)
Sets the document to be used for this JTextField. This sets the document property filterNewlines to true and then calls the super behaviour to setup a view and revalidate the text field.


getUIClassID

public java.lang.String getUIClassID()
Returns the class ID for the UI.


addActionListener

public void addActionListener(java.awt.event.ActionListener listener)
Adds a new listener object to this text field.


removeActionListener

public void removeActionListener(java.awt.event.ActionListener listener)
Removes a listener object from this text field.


getActionListeners

public java.awt.event.ActionListener[] getActionListeners()
Returns all registered ActionListener objects.

Since:
1.4

fireActionPerformed

protected void fireActionPerformed()
Sends an action event to all registered ActionListener objects.


getColumns

public int getColumns()
Returns the number of columns of this text field.


setColumns

public void setColumns(int columns)
Sets the number of columns and then invalidates the layout.


getHorizontalAlignment

public int getHorizontalAlignment()
Returns the horizontal alignment, which is one of: JTextField.LEFT, JTextField.CENTER, JTextField.RIGHT, JTextField.LEADING, JTextField.TRAILING.


setHorizontalAlignment

public void setHorizontalAlignment(int newAlign)
Sets the horizontal alignment of the text. Calls invalidate and repaint and fires a property change event.


setFont

public void setFont(java.awt.Font newFont)
Sets the current font and revalidates so the font will take effect.

Overrides:
setFont in class JComponent

getPreferredSize

public java.awt.Dimension getPreferredSize()
Returns the preferred size. If there is a non-zero number of columns, this is the number of columns multiplied by the column width, otherwise it returns super.getPreferredSize().

Overrides:
getPreferredSize in class JComponent

getScrollOffset

public int getScrollOffset()
Returns the scroll offset in pixels.


setScrollOffset

public void setScrollOffset(int offset)
Sets the scroll offset in pixels.


getActions

public Action[] getActions()
Returns the set of Actions that are commands for the editor. This is the actions supported by this editor plus the actions of the UI (returned by JTextComponent.getActions()).


postActionEvent

public void postActionEvent()

getAction

public Action getAction()
Since:
1.3

setAction

public void setAction(Action newAction)
Since:
1.3

setActionCommand

public void setActionCommand(java.lang.String command)
Sets the command string used in action events.

Since:
1.3

createActionPropertyChangeListener

protected java.beans.PropertyChangeListener createActionPropertyChangeListener(Action action)
Since:
1.3

configurePropertiesFromAction

protected void configurePropertiesFromAction(Action action)
Since:
1.3

getColumnWidth

protected int getColumnWidth()
Returns the column width, which is the width of the character m for the font in use.


getAccessibleContext

public javax.accessibility.AccessibleContext getAccessibleContext()
Returns the accessible context associated with the JTextField.

Specified by:
getAccessibleContext in interface javax.accessibility.Accessible

getHorizontalVisibility

public BoundedRangeModel getHorizontalVisibility()
Returns the bounded range model that describes the horizontal visibility of the text field in the case when the text does not fit into the available space. The actual values of this model are managed by the look and feel implementation.


isValidateRoot

public boolean isValidateRoot()
Returns true, unless this is embedded in a JViewport in which case the viewport takes responsibility of validating.

Overrides:
isValidateRoot in class JComponent

scrollRectToVisible

public void scrollRectToVisible(java.awt.Rectangle r)
Description copied from class: JComponent
Calls scrollRectToVisible on the component's parent. Components which can service this call should override.

Overrides:
scrollRectToVisible in class JComponent