|
||||||||||
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)
|
protected abstract JTextComponent |
createPromptComponent()
Creates a component which should be used to render the prompt text. |
void |
damageRange(JTextComponent t,
int p0,
int p1)
|
void |
damageRange(JTextComponent t,
int p0,
int p1,
Position.Bias firstBias,
Position.Bias secondBias)
|
boolean |
equals(Object obj)
|
Accessible |
getAccessibleChild(JComponent c,
int i)
|
int |
getAccessibleChildrenCount(JComponent c)
|
int |
getBaseline(JComponent c,
int width,
int height)
Tries to call ComponentUI#getBaseline(int, int) on the delegate
via Reflection. |
EditorKit |
getEditorKit(JTextComponent t)
|
Dimension |
getMaximumSize(JComponent c)
|
Dimension |
getMinimumSize(JComponent c)
|
int |
getNextVisualPositionFrom(JTextComponent t,
int pos,
Position.Bias b,
int direction,
Position.Bias[] biasRet)
|
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)
|
String |
getToolTipText(JTextComponent t,
Point pt)
|
int |
hashCode()
|
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()
|
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)
|
int |
viewToModel(JTextComponent t,
Point pt,
Position.Bias[] biasReturn)
|
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
public void uninstallUI(JComponent c)
uninstallUI
in class ComponentUI
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
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
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
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
BadLocationException
public Rectangle modelToView(JTextComponent t, int pos) throws BadLocationException
#modelToView(JTextComponent, int, Bias)
with
Position.Bias.Forward
.
modelToView
in class TextUI
BadLocationException
public boolean contains(JComponent c, int x, int y)
contains
in class ComponentUI
public void damageRange(JTextComponent t, int p0, int p1, Position.Bias firstBias, Position.Bias secondBias)
damageRange
in class TextUI
public void damageRange(JTextComponent t, int p0, int p1)
damageRange
in class TextUI
public boolean equals(Object obj)
equals
in class Object
public Accessible getAccessibleChild(JComponent c, int i)
getAccessibleChild
in class ComponentUI
public int getAccessibleChildrenCount(JComponent c)
getAccessibleChildrenCount
in class ComponentUI
public EditorKit getEditorKit(JTextComponent t)
getEditorKit
in class TextUI
public Dimension getMaximumSize(JComponent c)
getMaximumSize
in class ComponentUI
public Dimension getMinimumSize(JComponent c)
getMinimumSize
in class ComponentUI
public int getNextVisualPositionFrom(JTextComponent t, int pos, Position.Bias b, int direction, Position.Bias[] biasRet) throws BadLocationException
getNextVisualPositionFrom
in class TextUI
BadLocationException
public View getRootView(JTextComponent t)
getRootView
in class TextUI
public String getToolTipText(JTextComponent t, Point pt)
getToolTipText
in class TextUI
public int hashCode()
hashCode
in class Object
public String toString()
toString
in class Object
public int viewToModel(JTextComponent t, Point pt, Position.Bias[] biasReturn)
viewToModel
in class TextUI
public int viewToModel(JTextComponent t, Point pt)
viewToModel
in class TextUI
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
getBaseline
could not be
invoked on the delegate.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |