|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.text.JTextComponent
javax.swing.JTextField
public class JTextField
Nested Class Summary | |
---|---|
protected class |
JTextField.AccessibleJTextField
AccessibleJTextField |
Nested classes/interfaces inherited from class javax.swing.text.JTextComponent |
---|
JTextComponent.AccessibleJTextComponent, JTextComponent.KeyBinding |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
static String |
notifyAction
Name of the action that gets sent when the content of the text field gets accepted. |
Fields inherited from class javax.swing.text.JTextComponent |
---|
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, 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 | |
---|---|
JTextField()
Creates a new instance of JTextField . |
|
JTextField(Document doc,
String text,
int columns)
Creates a new instance of JTextField . |
|
JTextField(int columns)
Creates a new instance of JTextField . |
|
JTextField(String text)
Creates a new instance of JTextField . |
|
JTextField(String text,
int columns)
Creates a new instance of JTextField . |
Method Summary | |
---|---|
void |
addActionListener(ActionListener listener)
Adds a new listener object to this text field. |
protected void |
configurePropertiesFromAction(Action action)
|
protected PropertyChangeListener |
createActionPropertyChangeListener(Action action)
|
protected Document |
createDefaultModel()
Creates the default model for this text field. |
protected void |
fireActionPerformed()
Sends an action event to all registered ActionListener objects. |
AccessibleContext |
getAccessibleContext()
Returns the accessible context associated with the JTextField . |
Action |
getAction()
|
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. |
Dimension |
getPreferredSize()
Returns the preferred size. |
int |
getScrollOffset()
Returns the scroll offset in pixels. |
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(ActionListener listener)
Removes a listener object from this text field. |
void |
scrollRectToVisible(Rectangle r)
Calls scrollRectToVisible on the component's parent. |
void |
setAction(Action newAction)
|
void |
setActionCommand(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(Document doc)
Sets the document to be used for this JTextField. |
void |
setFont(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 java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String notifyAction
Constructor Detail |
---|
public JTextField()
JTextField
.
public JTextField(String text)
JTextField
.
text
- the initial textpublic JTextField(int columns)
JTextField
.
columns
- the number of columns
IllegalArgumentException
- if columns %lt; 0public JTextField(String text, int columns)
JTextField
.
text
- the initial textcolumns
- the number of columns
IllegalArgumentException
- if columns %lt; 0public JTextField(Document doc, String text, int columns)
JTextField
.
doc
- the document to usetext
- the initial textcolumns
- the number of columns
IllegalArgumentException
- if columns %lt; 0Method Detail |
---|
protected Document createDefaultModel()
PlainDocument
.
public void setDocument(Document doc)
filterNewlines
to
true
and then calls the super behaviour to setup a view and
revalidate the text field.
setDocument
in class JTextComponent
doc
- the document to setpublic String getUIClassID()
getUIClassID
in class JTextComponent
JComponent.setUI(javax.swing.plaf.ComponentUI)
,
JComponent.updateUI()
public void addActionListener(ActionListener listener)
listener
- the listener to addpublic void removeActionListener(ActionListener listener)
listener
- the listener to removepublic ActionListener[] getActionListeners()
ActionListener
objects.
protected void fireActionPerformed()
ActionListener
objects.
public int getColumns()
public void setColumns(int columns)
columns
- the number of columns
IllegalArgumentException
- if columns < 0public int getHorizontalAlignment()
public void setHorizontalAlignment(int newAlign)
newAlign
- must be one of: JTextField.LEFT, JTextField.CENTER,
JTextField.RIGHT, JTextField.LEADING, JTextField.TRAILING.
IllegalArgumentException
- if newAlign is not one of the above.public void setFont(Font newFont)
setFont
in class JComponent
newFont
- The new value of the propertyComponent.getFont()
public Dimension getPreferredSize()
getPreferredSize
in class JComponent
Component.setPreferredSize(java.awt.Dimension)
,
Component.getPreferredSize()
,
Component.isPreferredSizeSet()
,
ComponentUI.getPreferredSize(JComponent)
public int getScrollOffset()
public void setScrollOffset(int offset)
offset
- the scroll offsetpublic Action[] getActions()
getActions
in class JTextComponent
EditorKit
TextUI.getEditorKit(javax.swing.text.JTextComponent)
,
EditorKit.getActions()
public void postActionEvent()
public Action getAction()
public void setAction(Action newAction)
public void setActionCommand(String command)
protected PropertyChangeListener createActionPropertyChangeListener(Action action)
protected void configurePropertiesFromAction(Action action)
protected int getColumnWidth()
public AccessibleContext getAccessibleContext()
JTextField
.
getAccessibleContext
in interface Accessible
getAccessibleContext
in class JTextComponent
JTextField
public BoundedRangeModel getHorizontalVisibility()
public boolean isValidateRoot()
true
, unless this is embedded in a
JViewport
in which case the viewport takes responsibility of
validating.
isValidateRoot
in class JComponent
true
, unless this is embedded in a
JViewport
in which case the viewport takes
responsibility of validatingpublic void scrollRectToVisible(Rectangle r)
JComponent
scrollRectToVisible
on the component's parent.
Components which can service this call should override.
scrollRectToVisible
in class JComponent
r
- The rectangle to make visible
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |