Java Reference
In-Depth Information
Figure 16-2 shows some of the available operations for a JTextArea . When you select the
different menu options, the JTextComponent is appropriately affected.
Figure 16-2. TextAction list usage demonstration
This technique is useful because it shows that you can readily discover the supported
operations of a text component and provide access to that behavior without knowing precisely
what the actual behavior is. This is just one demonstration of the many ways you can use
TextAction objects.
Finding Actions
Although listing and using Action objects related to a text component is a fairly malleable
process, unless you know what you're looking for, it isn't very useful. Thankfully, the
DefaultEditorKit has 46 class constants that match many of the shared 46 (out of 53) Action
objects of all the text components. The class constants' names more or less reflect their function-
ality. The JTextField adds an additional constant for the Action shared with JFormattedTextField
and JPasswordField . Unfortunately, the names associated with the extra actions available to
the JTextPane aren't class constants of any text component and are just used internally within
the StyledEditorKit , where you will find the additional Action implementations defined.
Note One additional Action exists primarily for debugging purposes. Its Action name is dump-model ,
and it lacks a class constant to go with it. When initiated, the method literally dumps out the Document model
Element structure for the text component.
Table 16-1 lists the 47 constants available to help you locate the predefined Action you're
seeking.
 
Search WWH ::




Custom Search