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


Java JTextPane.putClientProperty方法代码示例

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


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

示例1: getHighlights

import javax.swing.JTextPane; //导入方法依赖的package包/类
private List<Highlight> getHighlights(JTextPane pane) {
    List<Highlight> highlights = (List<Highlight>) pane.getClientProperty(HIGHLIGHTS_PROPERTY);
    if(highlights == null) {
        highlights = new LinkedList<Highlight>();
        pane.putClientProperty(HIGHLIGHTS_PROPERTY, highlights);
    }
    return highlights;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:FindTypesSupport.java

示例2: getElementsComponent

import javax.swing.JTextPane; //导入方法依赖的package包/类
private JComponent getElementsComponent (String msg) {
    JTextPane area = new JTextPane ();
    area.setEditable (false);
    area.setContentType ("text/html"); // NOI18N
    area.setText (msg);
    area.setOpaque (false);
    area.setBackground(new Color(0, 0, 0, 0));
    area.putClientProperty( JTextPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE );
    return area;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:OperationPanel.java

示例3: mouseMoved

import javax.swing.JTextPane; //导入方法依赖的package包/类
@Override
    public void mouseMoved(MouseEvent e) {
        JTextPane pane = (JTextPane)e.getSource();
        StyledDocument doc = pane.getStyledDocument();

        int offset = pane.viewToModel(e.getPoint());
        Element elem = doc.getCharacterElement(offset);

        Highlight h = getHighlight(pane, offset);
        Highlight prevHighlight = (Highlight) pane.getClientProperty(PREV_HIGHLIGHT_PROPERTY);
        AttributeSet prevAs = (AttributeSet) pane.getClientProperty(PREV_HIGHLIGHT_ATTRIBUTES);
//        if(h != null && h.equals(prevHighlight)) {
//            return; // nothing to do
//        } else 
        if(prevHighlight != null && prevAs != null) {
            doc.setCharacterAttributes(prevHighlight.startOffset, prevHighlight.endOffset - prevHighlight.startOffset, prevAs, true);
            pane.putClientProperty(PREV_HIGHLIGHT_PROPERTY, null);
            pane.putClientProperty(PREV_HIGHLIGHT_ATTRIBUTES, null);
        }

        int modifiers = e.getModifiers() | e.getModifiersEx();
        if ( (modifiers & InputEvent.CTRL_DOWN_MASK) == InputEvent.CTRL_DOWN_MASK ||
             (modifiers & InputEvent.META_DOWN_MASK) == InputEvent.META_DOWN_MASK) 
        {            
            AttributeSet as = elem.getAttributes();
            if (StyleConstants.isUnderline(as)) {
                // do not underline whats already underlined
                return;
            }

            Font font = doc.getFont(as);
            FontMetrics fontMetrics = pane.getFontMetrics(font);
            try {
                Rectangle rectangle = new Rectangle(
                        pane.modelToView(elem.getStartOffset()).x,
                        pane.modelToView(elem.getStartOffset()).y,
                        fontMetrics.stringWidth(doc.getText(elem.getStartOffset(), elem.getEndOffset() - elem.getStartOffset())),
                        fontMetrics.getHeight());

                if (h != null && offset < elem.getEndOffset() - 1 && rectangle.contains(e.getPoint())) {
                    Style hlStyle = doc.getStyle("regularBlue-findtype");               // NOI18N

                    pane.putClientProperty(PREV_HIGHLIGHT_ATTRIBUTES, as.copyAttributes());
                    doc.setCharacterAttributes(h.startOffset, h.endOffset - h.startOffset, hlStyle, true);
    //                doc.setCharacterAttributes(h.startOffset, h.endOffset - h.startOffset, as.copyAttributes(), true);
                    pane.putClientProperty(PREV_HIGHLIGHT_PROPERTY, h);
                } 
            } catch (BadLocationException ex) {
                Exceptions.printStackTrace(ex);
            }
        }
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:53,代码来源:FindTypesSupport.java


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