Java Reference
In-Depth Information
JTextField Properties
Table 15-2 lists the 14 properties of JTextField .
Table 15-2. JTextField Properties
Property Name
Data Type
Access
accessibleContext
AccessibleContext
Read-only
actionCommand
String
Write-only
action
Action
Read-write bound
actionListeners
ActionListener[ ]
Read-only
actions
Action[ ]
Read-only
columns
int
Read-write
document
Document
Write-only bound
font
Font
Write-only
horizontalAlignment
int
Read-write bound
horizontalVisibility
BoundedRangeModel
Read-only
preferredSize
Dimension
Read-only
scrollOffset
int
Read-write
UIClassID
String
Read-only
validateRoot
boolean
Read-only
There's a tight coupling between the horizontalVisibility and scrollOffset properties.
The BoundedRangeModel for the horizontalVisibility property of JTextField represents the
width range required for displaying the contents of the text field. If there isn't enough space to
display the contents, the scrollOffset setting reflects how far off to the left the text has scrolled. As
the user navigates through the text within the JTextField , the scrollOffset value is automati-
cally updated. For example, the text field in Figure 15-4 contains the 26 letters of the alphabet
plus the 10 cardinal numbers: ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 . Not all these
characters fit in the field; therefore, the letters A through J have scrolled off to the left.
Figure 15-4. The scrollOffset property reflects how far to the left the field's contents have scrolled;
here, it is not at zero, so the beginning contents (A-J) have scrolled off to the left.
 
Search WWH ::




Custom Search