javax.swing.JTextPane#setCursor ( )源码实例Demo

下面列出了javax.swing.JTextPane#setCursor ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: netbeans   文件: HyperlinkSupport.java
@Override
public void mouseMoved(MouseEvent e) {
    JTextPane pane = (JTextPane)e.getSource();
    StyledDocument doc = pane.getStyledDocument();
    Element elem = doc.getCharacterElement(pane.viewToModel(e.getPoint()));
    AttributeSet as = elem.getAttributes();
    if (StyleConstants.isUnderline(as)) {
        pane.setCursor(new Cursor(Cursor.HAND_CURSOR));
    } else {
        pane.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    }
}
 
源代码2 项目: bigtable-sql   文件: VersionPane.java
public void mouseMoved(MouseEvent ev) {
JTextPane editor = (JTextPane) ev.getSource();
editor.setEditable(false);
  Point pt = new Point(ev.getX(), ev.getY());
  int pos = editor.viewToModel(pt);
  if (pos >= 0) {
    Document eDoc = editor.getDocument();
    if (eDoc instanceof DefaultStyledDocument) {
      DefaultStyledDocument hdoc =
        (DefaultStyledDocument) eDoc;
      Element e = hdoc.getCharacterElement(pos);
      AttributeSet a = e.getAttributes();
      AttributeSet tagA = (AttributeSet) a.getAttribute(HTML.Tag.A);
      String href = null;
      if (tagA!=null){
          href = (String)tagA.getAttribute(HTML.Attribute.HREF);
      }
      if (href != null) {
          editor.setToolTipText(href);
          if (editor.getCursor().getType() != Cursor.HAND_CURSOR) {
              editor.setCursor(new Cursor(Cursor.HAND_CURSOR));
          }
      }
      else {
          editor.setToolTipText(null);
          if (editor.getCursor().getType() != Cursor.DEFAULT_CURSOR) {
              editor.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        }
      }
    }
  }
  else {
      editor.setToolTipText(null);
  }
}
 
源代码3 项目: wandora   文件: ApplicationXML.java
@Override
protected JComponent getTextComponent(String locator) throws Exception {
    JTextPane textComponent = new JTextPane();
    textComponent.setText(getContent(locator));
    textComponent.setFont(new Font("monospaced", Font.PLAIN, 12));
    textComponent.setEditable(false);
    textComponent.setCaretPosition(0);
    textComponent.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    return textComponent;
}
 
源代码4 项目: wandora   文件: Text.java
protected JComponent getTextComponent(String locator) throws Exception {
    JTextPane textComponent = new JTextPane();
    textComponent.setText(getContent(locator));
    textComponent.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    textComponent.setEditable(false);
    textComponent.setCaretPosition(0);
    return textComponent;
}