Basis of a text components look-and-feel. This provides the
basic editor view and controller services that may be useful
when creating a look-and-feel for an extension of
JTextComponent.
Most state is held in the associated JTextComponent
as bound properties, and the UI installs default values for the
various properties. This default will install something for
all of the properties. Typically, a LAF implementation will
do more however. At a minimum, a LAF would generally install
key bindings.
This class also provides some concurrency support if the
Document associated with the JTextComponent is a subclass of
AbstractDocument. Access to the View (or View hierarchy) is
serialized between any thread mutating the model and the Swing
event thread (which is expected to render, do model/view coordinate
translation, etc). Any access to the root view should first
acquire a read-lock on the AbstractDocument and release that lock
in a finally block.
An important method to define is the getPropertyPrefix method
which is used as the basis of the keys used to fetch defaults
from the UIManager. The string should reflect the type of
TextUI (eg. TextField, TextArea, etc) without the particular
LAF part of the name (eg Metal, Motif, etc).
To build a view of the model, one of the following strategies can be employed.
create method.
Warning
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications running
the same version of Swing. As of 1.4, support for long term storage
of all JavaBeans
has been added to the java.beans package.
Please see java..
| Modifier and Type | Class and Description |
|---|---|
| public static class | BasicTextUI.
Default implementation of the interface |
| pack-priv static class | |
| public static class | BasicTextUI.
Default implementation of the interface |
| pack-priv static class | BasicTextUI.
Listens for mouse events for the purposes of detecting drag gestures. |
| pack-priv class | BasicTextUI.
Registered in the ActionMap. |
| pack-priv class | BasicTextUI.
Root view that acts as a gateway between the component and the View hierarchy. |
| pack-priv class | BasicTextUI.
Wrapper for text actions to return isEnabled false in case editor is non editable |
| pack-priv static class | |
| pack-priv class | BasicTextUI.
Handles updates from various places. |
| Modifier and Type | Field and Description |
|---|---|
| private int | |
| private static final int | |
| private static final EditorKit | |
| private static final TransferHandler | |
| private static final Position. | |
| private final BasicTextUI. | |
| private static volatile BasicTextUI. | |
| private DefaultCaret | |
| pack-priv transient JTextComponent | |
| pack-priv transient boolean | |
| pack-priv transient BasicTextUI. | |
| private static BasicTextUI. | |
| pack-priv transient BasicTextUI. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public View | Returns: the viewthe element elem)Implements javax. Creates a view for an element. |
| public View | |
| pack-priv ActionMap | |
| protected Caret | |
| protected Highlighter | |
| protected Keymap | Returns: the keymapCreates the keymap to use for the text component, and installs any necessary bindings into it. |
| public void | damageRange(JTextComponent
the text component for which this UI is installed tc, int the beginning of the range >= 0 p0, int the end of the range >= p0 p1)Implements abstract javax. Causes the portion of the view responsible for the given part of the model to be repainted. |
| public void | damageRange(JTextComponent t, int
the beginning of the range >= 0 p0, int the end of the range >= p0 p1, Position.Implements abstract javax. Causes the portion of the view responsible for the given part of the model to be repainted. |
| pack-priv ActionMap | |
| protected final JTextComponent | Returns: the editor componentFetches the text component associated with this UI implementation. |
| private static BasicTextUI. | |
| public EditorKit | Returns: the editor capabilitiesthe text component for which this UI is installed tc)Implements abstract javax. Fetches the EditorKit for the UI. |
| pack-priv InputMap | |
| protected String | Returns: the nameFetches the name of the keymap that will be installed/used by default for this UI. |
| public Dimension | Returns: the sizethe editor component c)Overrides javax. Gets the maximum size for the editor component. |
| public Dimension | Returns: the sizethe editor component c)Overrides javax. Gets the minimum size for the editor component. |
| public int | getNextVisualPositionFrom(JTextComponent t, int pos, Position.
Implements abstract javax. Provides a way to determine the next visually represented model location that one might place a caret. |
| public Dimension | Returns: the sizethe editor component c)Overrides javax. Gets the preferred size for the editor component. |
| protected abstract String | Returns: the nameGets the name used as a key to look up properties through the UIManager. |
| public View | Returns: the viewthe text component for which this UI is installed tc)Implements abstract javax. Fetches a View with the allocation of the associated text component (i.e. the root of the hierarchy) that can be traversed to determine how the model is being represented spatially. |
| public String | getToolTipText(JTextComponent t, Point pt)
Overrides javax. Returns the string to be used as the tooltip at the passed in location. |
| pack-priv TransferHandler | getTransferHandler()
Returns the |
| protected Rectangle | Returns: the bounding box for the root viewGets the allocation (that is the allocated size) for the root view. |
| protected void | installDefaults()
Initializes component properties, such as font, foreground, background, caret color, selection color, selected text color, disabled text color, border, and margin. |
| private void | |
| protected void | |
| protected void | |
| public void | installUI(JComponent
the editor component c)Overrides javax. Installs the UI for a component. |
| protected void | |
| public Rectangle | Returns: the coordinates as a rectangle, null if the model is not paintedthe text component for which this UI is installed tc, int the local location in the model to translate >= 0 pos)Implements abstract javax.
Deprecated
since 9. replaced by
modelToView2D(JTextComponent, int, Position.
Converts the given location in the model to a place in the view coordinate system. |
| public Rectangle | Returns: the coordinates as a rectangle, null if the model is not paintedthe text component for which this UI is installed tc, int the local location in the model to translate >= 0 pos, Position.Implements abstract javax.
Deprecated
since 9. replaced by
modelToView2D(JTextComponent, int, Position.
Converts the given location in the model to a place in the view coordinate system. |
| private Rectangle2D | |
| public Rectangle2D | modelToView2D(JTextComponent tc, int pos, Position.
Overrides javax. Converts the given location in the model to a place in the view coordinate system. |
| public final void | paint(Graphics
the graphics context g, JComponent the editor component c)Overrides javax. Paints the interface. |
| protected void | |
| protected void | paintSafely(Graphics
the graphics context g)Paints the interface safely with a guarantee that the model won't change from the view of this thread. |
| protected void | propertyChange(PropertyChangeEvent
the property change event evt)This method gets called when a bound property is changed on the associated JTextComponent. |
| protected final void | |
| protected void | |
| protected void | |
| protected void | |
| public void | uninstallUI(JComponent
the editor component c)Overrides javax. Deinstalls the UI for a component. |
| public void | update(Graphics g, JComponent c)
Overrides javax. Superclass paints background in an uncontrollable way (i.e. one might want an image tiled into the background). |
| private void | updateBackground(JTextComponent
the JTextComponent that needs its background color updated c)Updates the background of the text component based on whether the text component is editable and/or enabled. |
| private void | |
| pack-priv void | updateFocusAcceleratorBinding(boolean changed)
Invoked when the focus accelerator changes, this will update the key bindings as necessary. |
| pack-priv void | |
| public int | Returns: the offset from the start of the document >= 0, -1 if not paintedthe text component for which this UI is installed tc, Point the location in the view to translate. This
should be in the same coordinate system as the mouse events. pt)Implements abstract javax.
Deprecated
since 9. replaced by
viewToModel2D(JTextComponent, Point2D, Position.
Converts the given place in the view coordinate system to the nearest representative location in the model. |
| public int | Returns: the offset from the start of the document >= 0, -1 if the component doesn't yet have a positive size.the text component for which this UI is installed tc, Point the location in the view to translate. This
should be in the same coordinate system as the mouse events. pt, Position.Implements abstract javax.
Deprecated
since 9. replaced by
viewToModel2D(JTextComponent, Point2D, Position.
Converts the given place in the view coordinate system to the nearest representative location in the model. |
| private int | |
| public int | viewToModel2D(JTextComponent tc, Point2D pt, Position.
Overrides javax. Provides a mapping from the view coordinate space to the logical coordinate space of the model. |