本文整理汇总了Java中org.jdesktop.swingx.prompt.PromptSupport.FocusBehavior.HIGHLIGHT_PROMPT属性的典型用法代码示例。如果您正苦于以下问题:Java FocusBehavior.HIGHLIGHT_PROMPT属性的具体用法?Java FocusBehavior.HIGHLIGHT_PROMPT怎么用?Java FocusBehavior.HIGHLIGHT_PROMPT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.jdesktop.swingx.prompt.PromptSupport.FocusBehavior
的用法示例。
在下文中一共展示了FocusBehavior.HIGHLIGHT_PROMPT属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPromptComponent
/**
* Creates a label component, if none has already been created. Sets the
* prompt components properties to reflect the given {@link JTextComponent}s
* properties and returns it.
*
* @param txt
* @return the adjusted prompt component
*/
public JTextComponent getPromptComponent(JTextComponent txt) {
if (promptComponent == null) {
promptComponent = createPromptComponent();
}
if (txt.isFocusOwner()
&& PromptSupport.getFocusBehavior(txt) == FocusBehavior.HIDE_PROMPT) {
promptComponent.setText(null);
} else {
promptComponent.setText(PromptSupport.getPrompt(txt));
}
promptComponent.getHighlighter().removeAllHighlights();
if (txt.isFocusOwner()
&& PromptSupport.getFocusBehavior(txt) == FocusBehavior.HIGHLIGHT_PROMPT) {
promptComponent.setForeground(txt.getSelectedTextColor());
try {
promptComponent.getHighlighter().addHighlight(0,
promptComponent.getText().length(),
new DefaultHighlightPainter(txt.getSelectionColor()));
} catch (BadLocationException e) {
e.printStackTrace();
}
} else {
promptComponent.setForeground(PromptSupport.getForeground(txt));
}
if (PromptSupport.getFontStyle(txt) == null) {
promptComponent.setFont(txt.getFont());
} else {
promptComponent.setFont(txt.getFont().deriveFont(
PromptSupport.getFontStyle(txt)));
}
promptComponent.setBackground(PromptSupport.getBackground(txt));
promptComponent.setHighlighter(new PainterHighlighter(PromptSupport
.getBackgroundPainter(txt)));
promptComponent.setEnabled(txt.isEnabled());
promptComponent.setOpaque(txt.isOpaque());
promptComponent.setBounds(txt.getBounds());
Border b = txt.getBorder();
if (b == null) {
promptComponent.setBorder(txt.getBorder());
} else {
Insets insets = b.getBorderInsets(txt);
promptComponent.setBorder(
createEmptyBorder(insets.top, insets.left, insets.bottom, insets.right));
}
promptComponent.setSelectedTextColor(txt.getSelectedTextColor());
promptComponent.setSelectionColor(txt.getSelectionColor());
promptComponent.setEditable(txt.isEditable());
promptComponent.setMargin(txt.getMargin());
return promptComponent;
}