javax.swing.JEditorPane.getVisibleRect()方法的使用及代码示例

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

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

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);

相关文章

JEditorPane类方法