本文整理了Java中javax.swing.JEditorPane.getVisibleRect()
方法的一些代码示例,展示了JEditorPane.getVisibleRect()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JEditorPane.getVisibleRect()
方法的具体详情如下:
包路径:javax.swing.JEditorPane
类名称:JEditorPane
方法名:getVisibleRect
暂无
代码示例来源:origin: org.sonarsource.sslr/sslr-toolkit
@Override
public void scrollSourceCodeTo(@Nullable AstNode astNode) {
if (astNode != null && astNode.hasToken()) {
int visibleLines = sourceCodeEditorPane.getVisibleRect().height / sourceCodeEditorPane.getFontMetrics(sourceCodeEditorPane.getFont()).getHeight();
int line = astNode.getToken().getLine() + visibleLines / 2;
try {
sourceCodeEditorPane.scrollRectToVisible(sourceCodeEditorPane.modelToView(0));
sourceCodeEditorPane.scrollRectToVisible(sourceCodeEditorPane.modelToView(lineOffsets.getOffset(line, 0)));
} catch (BadLocationException e) {
throw new RuntimeException(e);
}
}
}
代码示例来源:origin: org.codehaus.sonar.sslr/sslr-toolkit
@Override
public void scrollSourceCodeTo(@Nullable AstNode astNode) {
if (astNode != null && astNode.hasToken()) {
int visibleLines = sourceCodeEditorPane.getVisibleRect().height / sourceCodeEditorPane.getFontMetrics(sourceCodeEditorPane.getFont()).getHeight();
int line = astNode.getToken().getLine() + visibleLines / 2;
try {
sourceCodeEditorPane.scrollRectToVisible(sourceCodeEditorPane.modelToView(0));
sourceCodeEditorPane.scrollRectToVisible(sourceCodeEditorPane.modelToView(lineOffsets.getOffset(line, 0)));
} catch (BadLocationException e) {
throw Throwables.propagate(e);
}
}
}
代码示例来源:origin: SonarSource/sslr
@Override
public void scrollSourceCodeTo(@Nullable AstNode astNode) {
if (astNode != null && astNode.hasToken()) {
int visibleLines = sourceCodeEditorPane.getVisibleRect().height / sourceCodeEditorPane.getFontMetrics(sourceCodeEditorPane.getFont()).getHeight();
int line = astNode.getToken().getLine() + visibleLines / 2;
try {
sourceCodeEditorPane.scrollRectToVisible(sourceCodeEditorPane.modelToView(0));
sourceCodeEditorPane.scrollRectToVisible(sourceCodeEditorPane.modelToView(lineOffsets.getOffset(line, 0)));
} catch (BadLocationException e) {
throw new RuntimeException(e);
}
}
}
代码示例来源:origin: org.codehaus.sonar.sslr/sslr-devkit
private void scrollToFirstSelectedPath() {
TreePath selectedPath = astTree.getSelectionPath();
if (selectedPath != null) {
DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) selectedPath.getLastPathComponent();
AstNode astNode = getAstNodeFromUserObject(treeNode.getUserObject());
int visibleLines = codeEditor.getVisibleRect().height / codeEditor.getFontMetrics(codeEditor.getFont()).getHeight();
int line = astNode.getToken().getLine() + visibleLines / 2;
try {
codeEditor.scrollRectToVisible(codeEditor.modelToView(0));
codeEditor.scrollRectToVisible(codeEditor.modelToView(lineOffsets.getOffset(line, 0)));
} catch (BadLocationException e) {
LOG.error("Error with the scrolling", e);
}
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-editor
Rectangle visibleRectangle = pane.getVisibleRect();
pane.setText(previewText);
pane.setIgnoreRepaint(true);
内容来源于网络,如有侵权,请联系作者删除!