|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jdesktop.swingx.prompt.PromptSupport
public class PromptSupport
Sets prompt text, foreground, background and PromptSupport.FocusBehavior
properties
on a JTextComponent by calling
JComponent.putClientProperty(Object, Object)
. These properties
are used by PromptTextUI
instances to render the prompt of a text
component.
This class is used by JXTextField
, JXFormattedTextField
and
JXTextArea
to get and set prompt properties. PromptTextUI
retrieves these properties using PromptSupport.
JXTextField
,
JXFormattedTextField
,
JXTextArea
,
PromptTextUI
Nested Class Summary | |
---|---|
static class |
PromptSupport.FocusBehavior
Determines how the JTextComponent is rendered when focused and no
text is present. |
Field Summary | |
---|---|
static String |
BACKGROUND
The prompt background property. |
static String |
BACKGROUND_PAINTER
The prompt background property. |
static String |
FOCUS_BEHAVIOR
The focus behavior property. |
static String |
FONT_STYLE
The font style property, if different from the components font. |
static String |
FOREGROUND
The color of the prompt text poroperty. |
static String |
PROMPT
The prompt text property. |
Constructor Summary | |
---|---|
PromptSupport()
|
Method Summary | |
---|---|
static Color |
getBackground(JTextComponent textComponent)
Get the background color of the textComponent , when no
text is present. |
static Painter |
getBackgroundPainter(JTextComponent textComponent)
Get the background painter of the textComponent , when no
text is present. |
static PromptSupport.FocusBehavior |
getFocusBehavior(JTextComponent textComponent)
Get the PromptSupport.FocusBehavior of textComponent . |
static Integer |
getFontStyle(JTextComponent textComponent)
Returns the font style of the prompt text, or null if the
prompt's font style should not differ from the textComponent s
font. |
static Color |
getForeground(JTextComponent textComponent)
Get the foreground color of the prompt text. |
static String |
getPrompt(JTextComponent textComponent)
Get the prompt text of textComponent . |
static void |
init(String promptText,
Color promptForeground,
Color promptBackground,
JTextComponent textComponent)
Convenience method to set the promptText and
promptTextColor on a JTextComponent . |
static void |
setBackground(Color background,
JTextComponent textComponent)
Sets the prompts background color on textComponent and
repaints the component to reflect the changes. |
static void |
setBackgroundPainter(Painter background,
JTextComponent textComponent)
Sets the prompts background painter on textComponent and
repaints the component to reflect the changes. |
static void |
setFocusBehavior(PromptSupport.FocusBehavior focusBehavior,
JTextComponent textComponent)
Sets the PromptSupport.FocusBehavior on textComponent and
repaints the component to reflect the changes, if it is the focus owner. |
static void |
setFontStyle(Integer fontStyle,
JTextComponent textComponent)
Set the style of the prompt font, if different from the textComponent s font. |
static void |
setForeground(Color promptTextColor,
JTextComponent textComponent)
Sets the foreground color of the prompt on textComponent
and repaints the component to reflect the changes. |
static void |
setPrompt(String promptText,
JTextComponent textComponent)
Sets the prompt text on textComponent . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String PROMPT
public static final String FOREGROUND
public static final String BACKGROUND
public static final String BACKGROUND_PAINTER
public static final String FOCUS_BEHAVIOR
public static final String FONT_STYLE
Constructor Detail |
---|
public PromptSupport()
Method Detail |
---|
public static void init(String promptText, Color promptForeground, Color promptBackground, JTextComponent textComponent)
Convenience method to set the promptText
and
promptTextColor
on a JTextComponent
.
If stayOnUIChange
is true, The prompt support will stay
installed, even when the text components UI changes. See
#install(JTextComponent, boolean)
.
promptText
- promptForeground
- promptBackground
- textComponent
- public static PromptSupport.FocusBehavior getFocusBehavior(JTextComponent textComponent)
PromptSupport.FocusBehavior
of textComponent
.
textComponent
-
PromptSupport.FocusBehavior
or PromptSupport.FocusBehavior.HIDE_PROMPT
if
none is setpublic static void setFocusBehavior(PromptSupport.FocusBehavior focusBehavior, JTextComponent textComponent)
PromptSupport.FocusBehavior
on textComponent
and
repaints the component to reflect the changes, if it is the focus owner.
focusBehavior
- textComponent
- public static String getPrompt(JTextComponent textComponent)
textComponent
.
textComponent
-
public static void setPrompt(String promptText, JTextComponent textComponent)
Sets the prompt text on textComponent
. Also sets the
tooltip text to the prompt text if textComponent
has no
tooltip text or the current tooltip text is the same as the current
prompt text.
Calls #install(JTextComponent)
to ensure that the
textComponent
s UI is wrapped by the appropriate
PromptTextUI
.
promptText
- textComponent
- public static Color getForeground(JTextComponent textComponent)
textComponent
s disabled text color will be returned.
textComponent
-
JTextComponent.getDisabledTextColor()
if none is setpublic static void setForeground(Color promptTextColor, JTextComponent textComponent)
textComponent
and repaints the component to reflect the changes. This color will be
used when no text is present.
promptTextColor
- textComponent
- public static Color getBackground(JTextComponent textComponent)
textComponent
, when no
text is present. If no color has been set, the textComponent
s
background color color will be returned.
textComponent
-
public static void setBackground(Color background, JTextComponent textComponent)
Sets the prompts background color on textComponent
and
repaints the component to reflect the changes. This background color will
only be used when no text is present.
Calls #install(JTextComponent)
to ensure that the
textComponent
s UI is wrapped by the appropriate
PromptTextUI
.
background
- textComponent
- public static Painter getBackgroundPainter(JTextComponent textComponent)
textComponent
, when no
text is present. If no painter has been set, then null
will be returned.
textComponent
-
public static void setBackgroundPainter(Painter background, JTextComponent textComponent)
Sets the prompts background painter on textComponent
and
repaints the component to reflect the changes. This background painter will
only be used when no text is present.
Calls #install(JTextComponent)
to ensure that the
textComponent
s UI is wrapped by the appropriate
PromptTextUI
.
background
- textComponent
- public static void setFontStyle(Integer fontStyle, JTextComponent textComponent)
Set the style of the prompt font, if different from the
textComponent
s font.
Allowed values are Font.PLAIN
, Font.ITALIC
,
Font.BOLD
, a combination of Font.BOLD
and
Font.ITALIC
or null
if the prompt font should be
the same as the textComponent
s font.
fontStyle
- textComponent
- public static Integer getFontStyle(JTextComponent textComponent)
null
if the
prompt's font style should not differ from the textComponent
s
font.
textComponent
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |