|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.plaf.ComponentUI
javax.swing.plaf.TextUI
org.jdesktop.swingx.plaf.PromptTextUI
public abstract class PromptTextUI
Abstract TextUI
class that delegates most work to another
TextUI
and additionally renders a prompt text as specified in the
JTextComponent
s client properties by PromptSupport
.
Subclasses of this class must provide a prompt component used for rendering the prompt text.
Nested Class Summary | |
---|---|
protected class |
PromptTextUI.PainterHighlighter
|
Field Summary | |
---|---|
protected TextUI |
delegate
Delegate the hard work to this object. |
protected JTextComponent |
promptComponent
This component ist painted when rendering the prompt text. |
Constructor Summary | |
---|---|
PromptTextUI(TextUI delegate)
Creates a new PromptTextUI which delegates most work to another
TextUI . |
Method Summary | |
---|---|
boolean |
contains(JComponent c,
int x,
int y)
Returns true if the specified x,y location is
contained within the look and feel's defined shape of the specified
component. |
protected abstract JTextComponent |
createPromptComponent()
Creates a component which should be used to render the prompt text. |
void |
damageRange(JTextComponent t,
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 firstBias,
Position.Bias secondBias)
Causes the portion of the view responsible for the given part of the model to be repainted. |
boolean |
equals(Object obj)
Indicates whether some other object is "equal to" this one. |
Accessible |
getAccessibleChild(JComponent c,
int i)
Returns the i th Accessible child of the object. |
int |
getAccessibleChildrenCount(JComponent c)
Returns the number of accessible children in the object. |
int |
getBaseline(JComponent c,
int width,
int height)
Tries to call ComponentUI#getBaseline(int, int) on the delegate
via Reflection. |
EditorKit |
getEditorKit(JTextComponent t)
Fetches the binding of services that set a policy for the type of document being edited. |
Dimension |
getMaximumSize(JComponent c)
Returns the specified component's maximum size appropriate for the look and feel. |
Dimension |
getMinimumSize(JComponent c)
Returns the specified component's minimum size appropriate for the look and feel. |
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)
When shouldPaintPrompt(JTextComponent) returns true, the prompt
component is retrieved by calling
getPromptComponent(JTextComponent) and it's preferred size is
returned. |
JTextComponent |
getPromptComponent(JTextComponent txt)
Creates a label component, if none has already been created. |
View |
getRootView(JTextComponent t)
Fetches a View with the allocation of the associated text component (i.e. |
String |
getToolTipText(JTextComponent t,
Point pt)
Returns the string to be used as the tooltip at the passed in location. |
int |
hashCode()
Returns a hash code value for the object. |
void |
installUI(JComponent c)
Calls TextUI#installUI(JComponent) on the delegate and installs a focus listener on c which repaints the component when it gains
or loses the focus. |
Rectangle |
modelToView(JTextComponent t,
int pos)
Calls #modelToView(JTextComponent, int, Bias) with
Position.Bias.Forward . |
Rectangle |
modelToView(JTextComponent t,
int pos,
Position.Bias bias)
Delegate when shouldPaintPrompt(JTextComponent) returns false. |
void |
paint(Graphics g,
JComponent c)
Delegates painting when shouldPaintPrompt(JTextComponent)
returns false. |
protected void |
paintPromptComponent(Graphics g,
JTextComponent txt)
|
boolean |
shouldPaintPrompt(JTextComponent txt)
Returns if the prompt or the text field should be painted, depending on the state of txt . |
String |
toString()
Returns a string representation of the object. |
void |
uninstallUI(JComponent c)
Delegates, then uninstalls the focus listener. |
void |
update(Graphics g,
JComponent c)
Calls super. update(Graphics, JComponent) , which in turn calls
the paint method of this object. |
int |
viewToModel(JTextComponent t,
Point pt)
Converts the given place in the view coordinate system to the nearest representative location in the model. |
int |
viewToModel(JTextComponent t,
Point pt,
Position.Bias[] biasReturn)
Provides a mapping from the view coordinate space to the logical coordinate space of the model. |
Methods inherited from class javax.swing.plaf.ComponentUI |
---|
createUI, getBaselineResizeBehavior |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected final TextUI delegate
protected JTextComponent promptComponent
Constructor Detail |
---|
public PromptTextUI(TextUI delegate)
PromptTextUI
which delegates most work to another
TextUI
.
delegate
- Method Detail |
---|
protected abstract JTextComponent createPromptComponent()
public void installUI(JComponent c)
c
which repaints the component when it gains
or loses the focus.
installUI
in class ComponentUI
c
- the component where this UI delegate is being installedComponentUI.uninstallUI(javax.swing.JComponent)
,
JComponent.setUI(javax.swing.plaf.ComponentUI)
,
JComponent.updateUI()
public void uninstallUI(JComponent c)
uninstallUI
in class ComponentUI
c
- the component from which this UI delegate is being removed;
this argument is often ignored,
but might be used if the UI object is stateless
and shared by multiple componentsComponentUI.installUI(javax.swing.JComponent)
,
JComponent.updateUI()
public JTextComponent getPromptComponent(JTextComponent txt)
JTextComponent
s
properties and returns it.
txt
-
public Dimension getPreferredSize(JComponent c)
shouldPaintPrompt(JTextComponent)
returns true, the prompt
component is retrieved by calling
getPromptComponent(JTextComponent)
and it's preferred size is
returned. Otherwise supergetPreferredSize(JComponent)
is
called.
getPreferredSize
in class ComponentUI
c
- the component whose preferred size is being queried;
this argument is often ignored,
but might be used if the UI object is stateless
and shared by multiple componentsJComponent.getPreferredSize()
,
LayoutManager.preferredLayoutSize(java.awt.Container)
public void paint(Graphics g, JComponent c)
shouldPaintPrompt(JTextComponent)
returns false. Otherwise the prompt component is retrieved by calling
getPromptComponent(JTextComponent)
and painted. Then the caret
of the given text component is painted.
paint
in class ComponentUI
g
- the Graphics
context in which to paintc
- the component being painted;
this argument is often ignored,
but might be used if the UI object is stateless
and shared by multiple componentsComponentUI.update(java.awt.Graphics, javax.swing.JComponent)
protected void paintPromptComponent(Graphics g, JTextComponent txt)
public boolean shouldPaintPrompt(JTextComponent txt)
txt
.
txt
-
txt
contains not text, otherwise falsepublic void update(Graphics g, JComponent c)
update(Graphics, JComponent)
, which in turn calls
the paint method of this object.
update
in class ComponentUI
g
- the Graphics
context in which to paintc
- the component being painted;
this argument is often ignored,
but might be used if the UI object is stateless
and shared by multiple componentsComponentUI.paint(java.awt.Graphics, javax.swing.JComponent)
,
JComponent.paintComponent(java.awt.Graphics)
public Rectangle modelToView(JTextComponent t, int pos, Position.Bias bias) throws BadLocationException
shouldPaintPrompt(JTextComponent)
returns false.
Otherwise get the prompt component's UI and delegate to it. This ensures
that the Caret
is painted on the correct position (this is
important when the text is centered, so that the caret will not be
painted inside the label text)
modelToView
in class TextUI
pos
- the local location in the model to translate >= 0
BadLocationException
- if the given position does not
represent a valid location in the associated documentpublic Rectangle modelToView(JTextComponent t, int pos) throws BadLocationException
#modelToView(JTextComponent, int, Bias)
with
Position.Bias.Forward
.
modelToView
in class TextUI
pos
- the local location in the model to translate >= 0
BadLocationException
- if the given position does not
represent a valid location in the associated documentpublic boolean contains(JComponent c, int x, int y)
javax.swing.plaf.ComponentUI
true
if the specified x,y location is
contained within the look and feel's defined shape of the specified
component. x
and y
are defined to be relative
to the coordinate system of the specified component. Although
a component's bounds
is constrained to a rectangle,
this method provides the means for defining a non-rectangular
shape within those bounds for the purpose of hit detection.
contains
in class ComponentUI
c
- the component where the x,y location is being queried;
this argument is often ignored,
but might be used if the UI object is stateless
and shared by multiple componentsx
- the x coordinate of the pointy
- the y coordinate of the pointJComponent.contains(int, int)
,
Component.contains(int, int)
public void damageRange(JTextComponent t, int p0, int p1, Position.Bias firstBias, Position.Bias secondBias)
javax.swing.plaf.TextUI
damageRange
in class TextUI
p0
- the beginning of the range >= 0p1
- the end of the range >= p0public void damageRange(JTextComponent t, int p0, int p1)
javax.swing.plaf.TextUI
damageRange
in class TextUI
p0
- the beginning of the range >= 0p1
- the end of the range >= p0public boolean equals(Object obj)
java.lang.Object
The equals
method implements an equivalence relation
on non-null object references:
x
, x.equals(x)
should return
true
.
x
and y
, x.equals(y)
should return true
if and only if
y.equals(x)
returns true
.
x
, y
, and z
, if
x.equals(y)
returns true
and
y.equals(z)
returns true
, then
x.equals(z)
should return true
.
x
and y
, multiple invocations of
x.equals(y) consistently return true
or consistently return false
, provided no
information used in equals
comparisons on the
objects is modified.
x
,
x.equals(null)
should return false
.
The equals method for class Object
implements
the most discriminating possible equivalence relation on objects;
that is, for any non-null reference values x
and
y
, this method returns true
if and only
if x
and y
refer to the same object
(x == y
has the value true
).
Note that it is generally necessary to override the hashCode method whenever this method is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes.
equals
in class Object
obj
- the reference object with which to compare.
true
if this object is the same as the obj
argument; false
otherwise.Object.hashCode()
,
Hashtable
public Accessible getAccessibleChild(JComponent c, int i)
javax.swing.plaf.ComponentUI
i
th Accessible
child of the object.
UIs might need to override this if they present areas on the
screen that can be viewed as components, but actual components
are not used for presenting those areas.
Note: As of v1.3, it is recommended that developers call
Component.AccessibleAWTComponent.getAccessibleChild()
instead of
this method.
getAccessibleChild
in class ComponentUI
i
- zero-based index of child
i
th Accessible
child of the objectComponentUI.getAccessibleChildrenCount(javax.swing.JComponent)
public int getAccessibleChildrenCount(JComponent c)
javax.swing.plaf.ComponentUI
Accessible
,
this
method should return the number of children of this object.
UIs might wish to override this if they present areas on the
screen that can be viewed as components, but actual components
are not used for presenting those areas.
Note: As of v1.3, it is recommended that developers call
Component.AccessibleAWTComponent.getAccessibleChildrenCount()
instead
of this method.
getAccessibleChildrenCount
in class ComponentUI
ComponentUI.getAccessibleChild(javax.swing.JComponent, int)
public EditorKit getEditorKit(JTextComponent t)
javax.swing.plaf.TextUI
getEditorKit
in class TextUI
public Dimension getMaximumSize(JComponent c)
javax.swing.plaf.ComponentUI
null
is returned, the maximum
size will be calculated by the component's layout manager instead
(this is the preferred approach for any component with a specific
layout manager installed). The default implementation of this
method invokes getPreferredSize
and returns that value.
getMaximumSize
in class ComponentUI
c
- the component whose maximum size is being queried;
this argument is often ignored,
but might be used if the UI object is stateless
and shared by multiple components
Dimension
object or null
JComponent.getMaximumSize()
,
LayoutManager2.maximumLayoutSize(java.awt.Container)
public Dimension getMinimumSize(JComponent c)
javax.swing.plaf.ComponentUI
null
is returned, the minimum
size will be calculated by the component's layout manager instead
(this is the preferred approach for any component with a specific
layout manager installed). The default implementation of this
method invokes getPreferredSize
and returns that value.
getMinimumSize
in class ComponentUI
c
- the component whose minimum size is being queried;
this argument is often ignored,
but might be used if the UI object is stateless
and shared by multiple components
Dimension
object or null
JComponent.getMinimumSize()
,
LayoutManager.minimumLayoutSize(java.awt.Container)
,
ComponentUI.getPreferredSize(javax.swing.JComponent)
public int getNextVisualPositionFrom(JTextComponent t, int pos, Position.Bias b, int direction, Position.Bias[] biasRet) throws BadLocationException
javax.swing.plaf.TextUI
getNextVisualPositionFrom
in class TextUI
t
- the text component for which this UI is installedpos
- the position to convert >= 0b
- the bias for the positiondirection
- 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.SOUTHbiasRet
- an array to contain the bias for the returned position
BadLocationException
public View getRootView(JTextComponent t)
javax.swing.plaf.TextUI
getRootView
in class TextUI
public String getToolTipText(JTextComponent t, Point pt)
javax.swing.plaf.TextUI
getToolTipText
in class TextUI
JTextComponent.getToolTipText(java.awt.event.MouseEvent)
public int hashCode()
java.lang.Object
java.util.Hashtable
.
The general contract of hashCode
is:
hashCode
method on each of
the two objects must produce the same integer result.
Object.equals(java.lang.Object)
method, then calling the hashCode method on each of the
two objects must produce distinct integer results. However, the
programmer should be aware that producing distinct integer results
for unequal objects may improve the performance of hashtables.
As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)
hashCode
in class Object
Object.equals(java.lang.Object)
,
Hashtable
public String toString()
java.lang.Object
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
toString
in class Object
public int viewToModel(JTextComponent t, Point pt, Position.Bias[] biasReturn)
javax.swing.plaf.TextUI
viewToModel
in class TextUI
pt
- the location in the view to translate.
This should be in the same coordinate system
as the mouse events.biasReturn
- filled in by this method to indicate whether
the point given is closer to the previous or the next
character in the model
public int viewToModel(JTextComponent t, Point pt)
javax.swing.plaf.TextUI
viewToModel
in class TextUI
pt
- the location in the view to translate. This
should be in the same coordinate system as the mouse
events.
public int getBaseline(JComponent c, int width, int height)
ComponentUI#getBaseline(int, int)
on the delegate
via Reflection. Workaround to maintain compatibility with Java 5. Ideally
we should also override ComponentUI.getBaselineResizeBehavior(JComponent)
,
but that's impossible since the Component.BaselineResizeBehavior
class,
which does not exist in Java 5, is involved.
getBaseline
in class ComponentUI
c
- JComponent
baseline is being requested forwidth
- the width to get the baseline forheight
- the height to get the baseline for
getBaseline
could not be
invoked on the delegate.JComponent.getBaseline(int,int)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |