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


Java JTextComponent.getSelectionColor方法代码示例

本文整理汇总了Java中javax.swing.text.JTextComponent.getSelectionColor方法的典型用法代码示例。如果您正苦于以下问题:Java JTextComponent.getSelectionColor方法的具体用法?Java JTextComponent.getSelectionColor怎么用?Java JTextComponent.getSelectionColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.text.JTextComponent的用法示例。


在下文中一共展示了JTextComponent.getSelectionColor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: paint

import javax.swing.text.JTextComponent; //导入方法依赖的package包/类
/** Renders the caret */
public @Override void paint(Graphics g) {
    JTextComponent c = component;
    if (c == null) return;

    // #70915 Check whether the caret was moved but the component was not
    // validated yet and therefore the caret bounds are still null
    // and if so compute the bounds and scroll the view if necessary.
    if (getDot() != 0 && caretBounds == null) {
        update(true);
    }
    if (LOG.isLoggable(Level.FINEST)) {
        LOG.finest("BaseCaret.paint(): caretBounds=" + caretBounds + dumpVisibility() + '\n');
    }
    if (caretBounds != null && isVisible() && blinkVisible) {
        paintCustomCaret(g);
    }
    if (rectangularSelection && rsPaintRect != null && g instanceof Graphics2D) {
        Graphics2D g2d = (Graphics2D) g;
        Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] {4, 2}, 0);
        Stroke origStroke = g2d.getStroke();
        Color origColor = g2d.getColor();
        try {
            // Render translucent rectangle
            Color selColor = c.getSelectionColor();
            g2d.setColor(selColor);
            Composite origComposite = g2d.getComposite();
            try {
                g2d.setComposite(AlphaComposite.SrcOver.derive(0.2f));
                g2d.fill(rsPaintRect);
            } finally {
                g2d.setComposite(origComposite);
            }
            // Paint stroked line around rectangular selection rectangle
            g.setColor(c.getCaretColor());
            g2d.setStroke(stroke);
            Rectangle onePointSmallerRect = new Rectangle(rsPaintRect);
            onePointSmallerRect.width--;
            onePointSmallerRect.height--;
            g2d.draw(onePointSmallerRect);

        } finally {
            g2d.setStroke(origStroke);
            g2d.setColor(origColor);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:48,代码来源:BaseCaret.java


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