|
Java Platform 1.2 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.swing.plaf.ComponentUI | +--javax.swing.plaf.TextUI | +--javax.swing.plaf.basic.BasicTextUI
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.
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(javax.swing.text.Element)
method.
#createViewFactory
method should be reimplemented to
return some factory.
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. A future release of Swing will provide support for long term persistence.
Inner Class Summary | |
static class |
BasicTextUI.BasicCaret
|
static class |
BasicTextUI.BasicHighlighter
|
Constructor Summary | |
BasicTextUI()
Creates a new UI. |
Method Summary | |
View |
create(Element elem)
Creates a view for an element. |
View |
create(Element elem,
int p0,
int p1)
Creates a view for an element. |
protected Caret |
createCaret()
Creates the object to use for a caret. |
protected Highlighter |
createHighlighter()
Creates the object to use for adding highlights. |
protected Keymap |
createKeymap()
Creates the keymap to use for the text component, and installs any necessary bindings into it. |
void |
damageRange(JTextComponent tc,
int p0,
int p1)
Causes the portion of the view responsible for the given part of the model to be repainted. |
void |
damageRange(JTextComponent t,
int p0,
int p1,
Position.Bias p0Bias,
Position.Bias p1Bias)
Causes the portion of the view responsible for the given part of the model to be repainted. |
protected JTextComponent |
getComponent()
Fetches the text component associated with this UI implementation. |
EditorKit |
getEditorKit(JTextComponent tc)
Fetches the EditorKit for the UI. |
protected String |
getKeymapName()
Fetches the name of the keymap that will be installed/used by default for this UI. |
Dimension |
getMaximumSize(JComponent c)
Gets the maximum size for the editor component. |
Dimension |
getMinimumSize(JComponent c)
Gets the minimum size for the editor component. |
int |
getNextVisualPositionFrom(JTextComponent t,
int pos,
Position.Bias b,
int direction,
Position.Bias[] biasRet)
Provides a way to determine the next visually represented model location that one might place a caret. |
Dimension |
getPreferredSize(JComponent c)
Gets the preferred size for the editor component. |
protected abstract String |
getPropertyPrefix()
Gets the name used as a key to look up properties through the UIManager. |
View |
getRootView(JTextComponent tc)
Fetches a View with the allocation of the associated text component (i.e. |
protected Rectangle |
getVisibleEditorRect()
Gets the portion of the editor visibile on the screen. |
protected void |
installDefaults()
Initializes component properties, e.g. |
protected void |
installKeyboardActions()
|
protected void |
installListeners()
Installs listeners for the UI. |
void |
installUI(JComponent c)
Installs the UI for a component. |
protected void |
modelChanged()
Flags model changes. |
Rectangle |
modelToView(JTextComponent tc,
int pos)
Converts the given location in the model to a place in the view coordinate system. |
Rectangle |
modelToView(JTextComponent tc,
int pos,
Position.Bias bias)
Converts the given location in the model to a place in the view coordinate system. |
void |
paint(Graphics g,
JComponent c)
Paints the interface. |
protected void |
paintBackground(Graphics g)
Paints a background for the view. |
protected void |
paintSafely(Graphics g)
Paints the interface safely with a guarantee that the model won't change from the view of this thread. |
protected void |
propertyChange(PropertyChangeEvent evt)
This method gets called when a bound property is changed on the associated JTextComponent. |
protected void |
setView(View v)
Sets the current root of the view hierarchy and calls invalidate(). |
protected void |
uninstallDefaults()
Sets the component properties that haven't been explicitly overriden to null. |
protected void |
uninstallKeyboardActions()
|
protected void |
uninstallListeners()
Uninstalls listeners for the UI. |
void |
uninstallUI(JComponent c)
Deinstalls the UI for a component. |
int |
viewToModel(JTextComponent tc,
Point pt)
Converts the given place in the view coordinate system to the nearest representative location in the model. |
int |
viewToModel(JTextComponent tc,
Point pt,
Position.Bias[] biasReturn)
Converts the given place in the view coordinate system to the nearest representative location in the model. |
Methods inherited from class javax.swing.plaf.ComponentUI |
contains,
createUI,
getAccessibleChild,
getAccessibleChildrenCount,
update |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public BasicTextUI()
Method Detail |
protected Caret createCaret()
protected Highlighter createHighlighter()
protected String getKeymapName()
protected Keymap createKeymap()
The set of bindings used to create the keymap is fetched
from the UIManager using a key formed by combining the
getPropertyPrefix()
method
and the string .keyBindings
. The type is expected
to be JTextComponent.KeyBinding[]
.
getKeymapName()
,
JTextComponent
protected void propertyChange(PropertyChangeEvent evt)
evt
- the property change eventprotected abstract String getPropertyPrefix()
protected void installDefaults()
uninstallDefaults()
,
installUI(javax.swing.JComponent)
protected void uninstallDefaults()
installDefaults()
,
uninstallUI(javax.swing.JComponent)
protected void installListeners()
protected void uninstallListeners()
protected void installKeyboardActions()
protected void uninstallKeyboardActions()
protected void paintBackground(Graphics g)
g
- the graphics contextprotected final JTextComponent getComponent()
protected void modelChanged()
protected final void setView(View v)
v
- the root viewprotected void paintSafely(Graphics g)
g
- the graphics contextpublic void installUI(JComponent c)
c
- the editor componentComponentUI.installUI(javax.swing.JComponent)
public void uninstallUI(JComponent c)
c
- the editor componentComponentUI.uninstallUI(javax.swing.JComponent)
public final void paint(Graphics g, JComponent c)
g
- the graphics contextc
- the editor componentpublic Dimension getPreferredSize(JComponent c)
c
- the editor componentpublic Dimension getMinimumSize(JComponent c)
c
- the editor componentpublic Dimension getMaximumSize(JComponent c)
c
- the editor componentprotected Rectangle getVisibleEditorRect()
public Rectangle modelToView(JTextComponent tc, int pos) throws BadLocationException
tc
- the text component for which this UI is installedpos
- the local location in the model to translate >= 0TextUI.modelToView(javax.swing.text.JTextComponent, int)
public Rectangle modelToView(JTextComponent tc, int pos, Position.Bias bias) throws BadLocationException
tc
- the text component for which this UI is installedpos
- the local location in the model to translate >= 0TextUI.modelToView(javax.swing.text.JTextComponent, int)
public int viewToModel(JTextComponent tc, Point pt)
tc
- the text component for which this UI is installedpt
- the location in the view to translate. This
should be in the same coordinate system as the mouse events.TextUI.viewToModel(javax.swing.text.JTextComponent, java.awt.Point)
public int viewToModel(JTextComponent tc, Point pt, Position.Bias[] biasReturn)
tc
- the text component for which this UI is installedpt
- the location in the view to translate. This
should be in the same coordinate system as the mouse events.TextUI.viewToModel(javax.swing.text.JTextComponent, java.awt.Point)
public int getNextVisualPositionFrom(JTextComponent t, int pos, Position.Bias b, int direction, Position.Bias[] biasRet) throws BadLocationException
pos
- the position to convert >= 0a
- the allocated region to render intodirection
- the direction from the current position that can
be thought of as the arrow keys typically found on a keyboard.
This may be SwingConstants.WEST, SwingConstants.EAST,
SwingConstants.NORTH, or SwingConstants.SOUTH.public void damageRange(JTextComponent tc, int p0, int p1)
tc
- the text component for which this UI is installedp0
- the beginning of the range >= 0p1
- the end of the range >= p0TextUI.damageRange(javax.swing.text.JTextComponent, int, int)
public void damageRange(JTextComponent t, int p0, int p1, Position.Bias p0Bias, Position.Bias p1Bias)
p0
- the beginning of the range >= 0p1
- the end of the range >= p0public EditorKit getEditorKit(JTextComponent tc)
tc
- the text component for which this UI is installedTextUI.getEditorKit(javax.swing.text.JTextComponent)
public View getRootView(JTextComponent tc)
tc
- the text component for which this UI is installedTextUI.getRootView(javax.swing.text.JTextComponent)
public View create(Element elem)
elem
- the elementpublic View create(Element elem, int p0, int p1)
elem
- the elementp0
- the starting offset >= 0p1
- the ending offset >= p0
|
Java Platform 1.2 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |