Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
javax.swing.plaf.ComponentUI
javax.swing.plaf.TextUI
javax.swing.plaf.basic.BasicTextUI
Nested Class Summary | |
static class |
|
static class |
|
Constructor Summary | |
|
Method Summary | |
View | |
View | |
protected Caret |
|
protected Highlighter |
|
protected Keymap |
|
void |
|
void |
|
protected JTextComponent |
|
EditorKit |
|
protected String |
|
Dimension |
|
Dimension |
|
int |
|
Dimension |
|
protected abstract String |
|
View |
|
protected Rectangle |
|
protected void |
|
protected void |
|
protected void |
|
void |
|
protected void |
|
Rectangle |
|
Rectangle |
|
void |
|
protected void |
|
protected void |
|
protected void |
|
protected void | |
protected void |
|
protected void |
|
protected void |
|
void |
|
void |
|
int |
|
int |
|
Methods inherited from class javax.swing.plaf.TextUI | |
damageRange , damageRange , getEditorKit , getNextVisualPositionFrom , getRootView , getToolTipText , modelToView , modelToView , viewToModel , viewToModel |
Methods inherited from class javax.swing.plaf.ComponentUI | |
contains , createUI , getAccessibleChild , getAccessibleChildrenCount , getMaximumSize , getMinimumSize , getPreferredSize , installUI , paint , uninstallUI , update |
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public View create(Element elem)
- Specified by:
- create in interface ViewFactory
- Parameters:
elem
- theElement
to create aView
for
- See Also:
ViewFactory
public View create(Element elem, int p0, int p1)
- Parameters:
elem
- theElement
to create aView
forp0
- the start offsetp1
- the end offset
- See Also:
ViewFactory
protected Caret createCaret()
Creates aCaret
that should be installed into the text component.
- Returns:
- a caret that should be installed into the text component
protected Highlighter createHighlighter()
Creates aHighlighter
that should be installed into the text component.
- Returns:
- a
Highlighter
for the text component
protected Keymap createKeymap()
Creates theKeymap
that is installed on the text component.
- Returns:
- the
Keymap
that is installed on the text component
public void damageRange(JTextComponent t, int p0, int p1)
Marks the specified range inside the text component's model as damaged and queues a repaint request.
- Overrides:
- damageRange in interface TextUI
- Parameters:
t
- the text componentp0
- the start location inside the document model of the range that is damagedp1
- the end location inside the document model of the range that is damaged
public void damageRange(JTextComponent t, int p0, int p1, Position.Bias firstBias, Position.Bias secondBias)
Marks the specified range inside the text component's model as damaged and queues a repaint request. This variant of this method allows aPosition.Bias
object to be specified for the start and end location of the range.
- Overrides:
- damageRange in interface TextUI
- Parameters:
t
- the text componentp0
- the start location inside the document model of the range that is damagedp1
- the end location inside the document model of the range that is damagedfirstBias
- the bias for the start locationsecondBias
- the bias for the end location
protected final JTextComponent getComponent()
The text component that is managed by this UI.
- Returns:
- the text component that is managed by this UI
public EditorKit getEditorKit(JTextComponent t)
Returns theEditorKit
used for the text component that is managed by this UI.
- Overrides:
- getEditorKit in interface TextUI
- Parameters:
t
- the text component
- Returns:
- the
EditorKit
used for the text component that is managed by this UI
protected String getKeymapName()
Returns the name of the keymap for this type of TextUI. This is implemented so that the classname of this TextUI without the package prefix is returned. This way subclasses don't have to override this method.
- Returns:
- the name of the keymap for this TextUI
public Dimension getMaximumSize(JComponent c)
Returns the maximum size for text components that use this UI. This returns (Integer.MAX_VALUE, Integer.MAX_VALUE).
- Overrides:
- getMaximumSize in interface ComponentUI
- Parameters:
c
- not used here
- Returns:
- the maximum size for text components that use this UI
public Dimension getMinimumSize(JComponent c)
Returns the minimum size for text components. This returns the size of the component's insets.
- Overrides:
- getMinimumSize in interface ComponentUI
- Returns:
- the minimum size for text components
public int getNextVisualPositionFrom(JTextComponent t, int pos, Position.Bias b, int direction, Position.Bias[] biasRet) throws BadLocationException
Gets the next position inside the document model that is visible on screen, starting frompos
.
- Overrides:
- getNextVisualPositionFrom in interface TextUI
- Parameters:
t
- the text componentpos
- the start positionnb
- the bias for posdirection
- the search directionbiasRet
- filled by the method to indicate the bias of the return value
- Returns:
- the next position inside the document model that is visible on screen
public Dimension getPreferredSize(JComponent c)
Returns the preferred size of the text component.
- Overrides:
- getPreferredSize in interface ComponentUI
- Parameters:
c
- not used here
- Returns:
- the preferred size of the text component
protected abstract String getPropertyPrefix()
Returns the property prefix by which the text component's UIDefaults are looked up.
- Returns:
- the property prefix by which the text component's UIDefaults are looked up
public View getRootView(JTextComponent t)
Returns the rootView
of a text component.
- Overrides:
- getRootView in interface TextUI
- Returns:
- the root
View
of a text component
protected Rectangle getVisibleEditorRect()
Returns the allocation to give the root view.
- Returns:
- the allocation to give the root view
protected void installKeyboardActions()
Installs the keyboard actions on the text components.
public void installUI(JComponent c)
Installs this UI on the text component.
- Overrides:
- installUI in interface ComponentUI
- Parameters:
c
- the text component on which to install the UI
protected void modelChanged()
Indicates that the model of a text component has changed. This triggers a rebuild of the view hierarchy.
public Rectangle modelToView(JTextComponent t, int pos) throws BadLocationException
Maps a position in the document into the coordinate space of the View. The output rectangle usually reflects the font height but has a width of zero. A bias ofPosition.Bias.Forward
is used in this method.
- Overrides:
- modelToView in interface TextUI
- Parameters:
t
- the text componentpos
- the position of the character in the model
- Returns:
- a rectangle that gives the location of the document position inside the view coordinate space
- Throws:
BadLocationException
- ifpos
is invalidIllegalArgumentException
- if b is not one of the above listed valid values
public Rectangle modelToView(JTextComponent t, int pos, Position.Bias bias) throws BadLocationException
Maps a position in the document into the coordinate space of the View. The output rectangle usually reflects the font height but has a width of zero.
- Overrides:
- modelToView in interface TextUI
- Parameters:
t
- the text componentpos
- the position of the character in the modelbias
- eitherPosition.Bias.Forward
orPosition.Bias.Backward
depending on the preferred direction bias. Ifnull
this defaults toPosition.Bias.Forward
- Returns:
- a rectangle that gives the location of the document position inside the view coordinate space
- Throws:
BadLocationException
- ifpos
is invalidIllegalArgumentException
- if b is not one of the above listed valid values
public final void paint(Graphics g, JComponent c)
Paints the text component. This acquires a read lock on the model and then callspaintSafely(Graphics)
in order to actually perform the painting.
- Overrides:
- paint in interface ComponentUI
- Parameters:
g
- theGraphics
context to paint toc
- not used here
protected void paintBackground(Graphics g)
Paints the background of the text component.
- Parameters:
g
- theGraphics
context to paint to
protected void paintSafely(Graphics g)
This paints the text component while beeing sure that the model is not modified while painting. The following is performed in this order:
- If the text component is opaque, the background is painted by calling
paintBackground(Graphics)
.- If there is a highlighter, the highlighter is painted.
- The view hierarchy is painted.
- The Caret is painter.
- Parameters:
g
- theGraphics
context to paint to
protected void propertyChange(PropertyChangeEvent ev)
Receives notification whenever one of the text component's bound properties changes. This default implementation does nothing. It is a hook that enables subclasses to react to property changes on the text component.
- Parameters:
ev
- the property change event
protected final void setView(View view)
Sets the root view for the text component.
- Parameters:
view
- theView
to be set as root view
protected void uninstallDefaults()
Uninstalls all default properties that have previously been installed by this UI.
protected void uninstallKeyboardActions()
Uninstalls all keyboard actions that have previously been installed by this UI.
protected void uninstallListeners()
Uninstalls all listeners that have previously been installed by this UI.
public void uninstallUI(JComponent component)
Uninstalls this TextUI from the text component.
- Overrides:
- uninstallUI in interface ComponentUI
- Parameters:
component
- the text component to uninstall the UI from
public void update(Graphics g, JComponent c)
Overridden for better control over background painting. This now simply callspaint(Graphics,JComponent)
and this delegates the background painting topaintBackground(Graphics)
.
- Overrides:
- update in interface ComponentUI
- Parameters:
g
- the graphics to usec
- the component to be painted
public int viewToModel(JTextComponent t, Point pt)
Maps a point in theView
coordinate space to a position inside a document model.
- Overrides:
- viewToModel in interface TextUI
- Parameters:
t
- the text componentpt
- the point to be mapped
- Returns:
- the position inside the document model that corresponds to
pt
public int viewToModel(JTextComponent t, Point pt, Position.Bias[] biasReturn)
Maps a point in theView
coordinate space to a position inside a document model.
- Overrides:
- viewToModel in interface TextUI
- Parameters:
t
- the text componentpt
- the point to be mappedbiasReturn
- filled in by the method to indicate the bias of the return value
- Returns:
- the position inside the document model that corresponds to
pt