|
|||||||||
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 javax.swing.plaf.TextUI |
delegate
Delegate the hard work to this object. |
protected javax.swing.text.JTextComponent |
promptComponent
This component ist painted when rendering the prompt text. |
Constructor Summary | |
---|---|
PromptTextUI(javax.swing.plaf.TextUI delegate)
Creates a new PromptTextUI which delegates most work to another
TextUI . |
Method Summary | |
---|---|
boolean |
contains(javax.swing.JComponent c,
int x,
int y)
|
protected abstract javax.swing.text.JTextComponent |
createPromptComponent()
Creates a component which should be used to render the prompt text. |
void |
damageRange(javax.swing.text.JTextComponent t,
int p0,
int p1)
|
void |
damageRange(javax.swing.text.JTextComponent t,
int p0,
int p1,
javax.swing.text.Position.Bias firstBias,
javax.swing.text.Position.Bias secondBias)
|
boolean |
equals(java.lang.Object obj)
|
javax.accessibility.Accessible |
getAccessibleChild(javax.swing.JComponent c,
int i)
|
int |
getAccessibleChildrenCount(javax.swing.JComponent c)
|
int |
getBaseline(javax.swing.JComponent c,
int width,
int height)
Tries to call ComponentUI#getBaseline(int, int) on the delegate
via Reflection. |
javax.swing.text.EditorKit |
getEditorKit(javax.swing.text.JTextComponent t)
|
java.awt.Dimension |
getMaximumSize(javax.swing.JComponent c)
|
java.awt.Dimension |
getMinimumSize(javax.swing.JComponent c)
|
int |
getNextVisualPositionFrom(javax.swing.text.JTextComponent t,
int pos,
javax.swing.text.Position.Bias b,
int direction,
javax.swing.text.Position.Bias[] biasRet)
|
java.awt.Dimension |
getPreferredSize(javax.swing.JComponent c)
When shouldPaintPrompt(JTextComponent) returns true, the prompt
component is retrieved by calling
getPromptComponent(JTextComponent) and it's preferred size is
returned. |
javax.swing.text.JTextComponent |
getPromptComponent(javax.swing.text.JTextComponent txt)
Creates a label component, if none has already been created. |
javax.swing.text.View |
getRootView(javax.swing.text.JTextComponent t)
|
java.lang.String |
getToolTipText(javax.swing.text.JTextComponent t,
java.awt.Point pt)
|
int |
hashCode()
|
void |
installUI(javax.swing.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. |
java.awt.Rectangle |
modelToView(javax.swing.text.JTextComponent t,
int pos)
Calls #modelToView(JTextComponent, int, Bias) with
Position.Bias.Forward . |
java.awt.Rectangle |
modelToView(javax.swing.text.JTextComponent t,
int pos,
javax.swing.text.Position.Bias bias)
Delegate when shouldPaintPrompt(JTextComponent) returns false. |
void |
paint(java.awt.Graphics g,
javax.swing.JComponent c)
Delegates painting when shouldPaintPrompt(JTextComponent)
returns false. |
protected void |
paintPromptComponent(java.awt.Graphics g,
javax.swing.text.JTextComponent txt)
|
boolean |
shouldPaintPrompt(javax.swing.text.JTextComponent txt)
Returns if the prompt or the text field should be painted, depending on the state of txt . |
java.lang.String |
toString()
|
void |
uninstallUI(javax.swing.JComponent c)
Delegates, then uninstalls the focus listener. |
void |
update(java.awt.Graphics g,
javax.swing.JComponent c)
Calls super. update(Graphics, JComponent) , which in turn calls
the paint method of this object. |
int |
viewToModel(javax.swing.text.JTextComponent t,
java.awt.Point pt)
|
int |
viewToModel(javax.swing.text.JTextComponent t,
java.awt.Point pt,
javax.swing.text.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 javax.swing.plaf.TextUI delegate
protected javax.swing.text.JTextComponent promptComponent
Constructor Detail |
---|
public PromptTextUI(javax.swing.plaf.TextUI delegate)
PromptTextUI
which delegates most work to another
TextUI
.
delegate
- Method Detail |
---|
protected abstract javax.swing.text.JTextComponent createPromptComponent()
public void installUI(javax.swing.JComponent c)
c
which repaints the component when it gains or
loses the focus.
installUI
in class javax.swing.plaf.ComponentUI
public void uninstallUI(javax.swing.JComponent c)
uninstallUI
in class javax.swing.plaf.ComponentUI
public javax.swing.text.JTextComponent getPromptComponent(javax.swing.text.JTextComponent txt)
JTextComponent
s
properties and returns it.
txt
-
public java.awt.Dimension getPreferredSize(javax.swing.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 javax.swing.plaf.ComponentUI
public void paint(java.awt.Graphics g, javax.swing.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 javax.swing.plaf.ComponentUI
protected void paintPromptComponent(java.awt.Graphics g, javax.swing.text.JTextComponent txt)
public boolean shouldPaintPrompt(javax.swing.text.JTextComponent txt)
txt
.
txt
-
txt
contains not text, otherwise falsepublic void update(java.awt.Graphics g, javax.swing.JComponent c)
update(Graphics, JComponent)
, which in turn calls
the paint method of this object.
update
in class javax.swing.plaf.ComponentUI
public java.awt.Rectangle modelToView(javax.swing.text.JTextComponent t, int pos, javax.swing.text.Position.Bias bias) throws javax.swing.text.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 javax.swing.plaf.TextUI
javax.swing.text.BadLocationException
public java.awt.Rectangle modelToView(javax.swing.text.JTextComponent t, int pos) throws javax.swing.text.BadLocationException
#modelToView(JTextComponent, int, Bias)
with
Position.Bias.Forward
.
modelToView
in class javax.swing.plaf.TextUI
javax.swing.text.BadLocationException
public boolean contains(javax.swing.JComponent c, int x, int y)
contains
in class javax.swing.plaf.ComponentUI
public void damageRange(javax.swing.text.JTextComponent t, int p0, int p1, javax.swing.text.Position.Bias firstBias, javax.swing.text.Position.Bias secondBias)
damageRange
in class javax.swing.plaf.TextUI
public void damageRange(javax.swing.text.JTextComponent t, int p0, int p1)
damageRange
in class javax.swing.plaf.TextUI
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public javax.accessibility.Accessible getAccessibleChild(javax.swing.JComponent c, int i)
getAccessibleChild
in class javax.swing.plaf.ComponentUI
public int getAccessibleChildrenCount(javax.swing.JComponent c)
getAccessibleChildrenCount
in class javax.swing.plaf.ComponentUI
public javax.swing.text.EditorKit getEditorKit(javax.swing.text.JTextComponent t)
getEditorKit
in class javax.swing.plaf.TextUI
public java.awt.Dimension getMaximumSize(javax.swing.JComponent c)
getMaximumSize
in class javax.swing.plaf.ComponentUI
public java.awt.Dimension getMinimumSize(javax.swing.JComponent c)
getMinimumSize
in class javax.swing.plaf.ComponentUI
public int getNextVisualPositionFrom(javax.swing.text.JTextComponent t, int pos, javax.swing.text.Position.Bias b, int direction, javax.swing.text.Position.Bias[] biasRet) throws javax.swing.text.BadLocationException
getNextVisualPositionFrom
in class javax.swing.plaf.TextUI
javax.swing.text.BadLocationException
public javax.swing.text.View getRootView(javax.swing.text.JTextComponent t)
getRootView
in class javax.swing.plaf.TextUI
public java.lang.String getToolTipText(javax.swing.text.JTextComponent t, java.awt.Point pt)
getToolTipText
in class javax.swing.plaf.TextUI
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public int viewToModel(javax.swing.text.JTextComponent t, java.awt.Point pt, javax.swing.text.Position.Bias[] biasReturn)
viewToModel
in class javax.swing.plaf.TextUI
public int viewToModel(javax.swing.text.JTextComponent t, java.awt.Point pt)
viewToModel
in class javax.swing.plaf.TextUI
public int getBaseline(javax.swing.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 javax.swing.plaf.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 |