当前位置: 首页>>代码示例>>Java>>正文


Java FocusBehavior.HIGHLIGHT_PROMPT属性代码示例

本文整理汇总了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;
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:64,代码来源:PromptTextUI.java


注:本文中的org.jdesktop.swingx.prompt.PromptSupport.FocusBehavior.HIGHLIGHT_PROMPT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。