javax.swing.JTextPane.scrollToReference()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(1.7k)|赞(0)|评价(0)|浏览(163)

本文整理了Java中javax.swing.JTextPane.scrollToReference()方法的一些代码示例,展示了JTextPane.scrollToReference()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextPane.scrollToReference()方法的具体详情如下:
包路径:javax.swing.JTextPane
类名称:JTextPane
方法名:scrollToReference

JTextPane.scrollToReference介绍

暂无

代码示例

代码示例来源:origin: chatty/chatty

/**
 * Jump to the given position (ref) in the current page
 * 
 * @param ref The position to jump to, if it is an empty String, then it
 * will scroll to the very top
 * @throws NullPointerException If {@code ref} is {@code null}
 */
private void jumpTo(final String ref) {
  if (ref.isEmpty()) {
    textPane.scrollRectToVisible(new Rectangle(0,0,1,1));
  } else {
    textPane.scrollToReference(ref);
  }
}

代码示例来源:origin: nroduit/Weasis

public SRView(Series<?> series) {
  JPanel panel = new JPanel();
  panel.setLayout(new BorderLayout());
  panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
  htmlPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
  htmlPanel.setEditorKit(JMVUtils.buildHTMLEditorKit(htmlPanel));
  htmlPanel.setContentType("text/html"); //$NON-NLS-1$
  htmlPanel.setEditable(false);
  htmlPanel.addHyperlinkListener(e -> {
    JTextPane pane = (JTextPane) e.getSource();
    if (e.getEventType() == HyperlinkEvent.EventType.ENTERED) {
      pane.setToolTipText(e.getDescription());
    } else if (e.getEventType() == HyperlinkEvent.EventType.EXITED) {
      pane.setToolTipText(null);
    } else if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
      String desc = e.getDescription();
      URL url = e.getURL();
      if (url == null && desc != null && desc.startsWith("#")) { //$NON-NLS-1$
        htmlPanel.scrollToReference(desc.substring(1));
      } else {
        openRelatedSeries(e.getURL().getHost());
      }
    }
  });
  setPreferredSize(new Dimension(1024, 1024));
  setSeries(series);
}

相关文章

JTextPane类方法