本文整理了Java中javax.swing.JEditorPane.scrollToReference()
方法的一些代码示例,展示了JEditorPane.scrollToReference()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JEditorPane.scrollToReference()
方法的具体详情如下:
包路径:javax.swing.JEditorPane
类名称:JEditorPane
方法名:scrollToReference
暂无
代码示例来源:origin: org.netbeans.api/org-openide-awt
@Override
public void scrollToReference(String reference) {
if( !isShowing() || null == getParent() || getWidth() < 1 || getHeight() < 1 )
return;
super.scrollToReference(reference);
}
代码示例来源:origin: com.fifesoft/autocomplete
@Override
public void actionPerformed(ActionEvent e) {
if (historyPos>0) {
HistoryEntry pair = history.get(--historyPos);
descArea.setText(pair.summary);
if (pair.anchor!=null) {
//System.out.println("Scrolling to: " + pair.anchor);
descArea.scrollToReference(pair.anchor);
}
else {
descArea.setCaretPosition(0);
}
setActionStates();
}
}
代码示例来源:origin: com.fifesoft/autocomplete
@Override
public void actionPerformed(ActionEvent e) {
if (history!=null && historyPos<history.size()-1) {
HistoryEntry pair = history.get(++historyPos);
descArea.setText(pair.summary);
if (pair.anchor!=null) {
//System.out.println("Scrolling to: " + pair.anchor);
descArea.scrollToReference(pair.anchor);
}
else {
descArea.setCaretPosition(0);
}
setActionStates();
}
}
代码示例来源:origin: net.imagej/ij
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
String url = e.getDescription(); //getURL does not work for relative links within document such as "#top"
if (url==null) return;
if (url.startsWith("#"))
editorPane.scrollToReference(url.substring(1));
else {
String macro = "run('URL...', 'url="+url+"');";
new MacroRunner(macro);
}
}
}
代码示例来源:origin: imagej/ImageJA
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
String url = e.getDescription(); //getURL does not work for relative links within document such as "#top"
if (url==null) return;
if (url.startsWith("#"))
editorPane.scrollToReference(url.substring(1));
else {
String macro = "run('URL...', 'url="+url+"');";
new MacroRunner(macro);
}
}
}
代码示例来源:origin: girtel/Net2Plan
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
try {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
String href = e.getDescription();
if (href.toLowerCase(Locale.getDefault()).startsWith("http")) HTMLUtils.browse(new URI(href));
else editor.scrollToReference(href.substring(1));
}
} catch (Throwable ex) {
ErrorHandling.addErrorOrException(ex, ReportBrowser.class);
ErrorHandling.showErrorDialog("Please, check console for more information", "Error exporting report");
}
}
});
代码示例来源:origin: stackoverflow.com
public static void main(final String[] args) {
final JFrame f = new JFrame();
f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
f.setTitle("JEditorPane Test");
final String text = "<html><body>xyz<br /><br /><br />lol <a name='link1'>test</a>some text<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />some more text<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />some more text<a href='#link1'>jump to top</a></body></html>";
final JEditorPane ep = new JEditorPane();
ep.setContentType("text/html");
ep.setText(text);
ep.setEditable(false);
ep.addHyperlinkListener(new HyperlinkListener() {
@Override public void hyperlinkUpdate(final HyperlinkEvent pE) {
if (HyperlinkEvent.EventType.ACTIVATED == pE.getEventType()) {
String desc = pE.getDescription();
if (desc == null || !desc.startsWith("#")) return;
desc = desc.substring(1);
ep.scrollToReference(desc);
}
}
});
final JScrollPane sp = new JScrollPane(ep);
f.add(sp);
f.setBounds(200, 200, 400, 400);
f.setVisible(true);
}
代码示例来源:origin: com.fifesoft.rtext/fife.common
editorPane.scrollToReference(anchor);
代码示例来源:origin: stackoverflow.com
if (e.getURL().sameFile(url)) {
try {
htmlPane.scrollToReference(e.getURL().getRef());
} catch (Throwable t) {
t.printStackTrace();
代码示例来源:origin: hneemann/Digital
private void init(Component parent, String description) {
JEditorPane editorPane = new JEditorPane("text/html", description);
editorPane.setEditable(false);
editorPane.setCaretPosition(0);
editorPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);
editorPane.addHyperlinkListener(hyperlinkEvent -> {
if (HyperlinkEvent.EventType.ACTIVATED == hyperlinkEvent.getEventType()) {
String desc = hyperlinkEvent.getDescription();
if (desc == null || !desc.startsWith("#")) return;
desc = desc.substring(1);
editorPane.scrollToReference(desc);
}
});
getContentPane().add(new JScrollPane(editorPane));
buttons = new JPanel(new FlowLayout(FlowLayout.RIGHT));
buttons.add(new JButton(new AbstractAction(Lang.get("ok")) {
@Override
public void actionPerformed(ActionEvent actionEvent) {
dispose();
}
}));
getContentPane().add(buttons, BorderLayout.SOUTH);
pack();
Dimension r = getSize();
if (r.width > MAX_WIDTH) r.width = MAX_WIDTH;
if (r.height > MAX_HEIGHT) r.height = MAX_HEIGHT;
setSize(Screen.getInstance().scale(r));
setLocationRelativeTo(parent);
}
代码示例来源:origin: stackoverflow.com
html.scrollToReference("three");
代码示例来源:origin: com.fifesoft/autocomplete
private void setDisplayedDesc(Completion completion, final String anchor,
boolean addToHistory) {
String desc = completion==null ? null : completion.getSummary();
if (desc==null) {
desc = "<html><em>" + getString("NoDescAvailable") + "</em>";
}
descArea.setText(desc);
if (anchor!=null) {
SwingUtilities.invokeLater(() -> descArea.scrollToReference(anchor));
}
else {
descArea.setCaretPosition(0); // In case of scrolling
}
if (!addToHistory) {
// Remove everything first if this is going to be the only
// thing in history.
clearHistory();
}
addToHistory(new HistoryEntry(completion, desc, null));
}
代码示例来源:origin: girtel/Net2Plan
ep.scrollToReference(hlInfo);
代码示例来源:origin: EngineHub/CommandHelper
if(elem != null) {
inputDialog.setCaretPosition(elem.getStartOffset());
inputDialog.scrollToReference(id);
内容来源于网络,如有侵权,请联系作者删除!