本文整理了Java中javax.swing.JEditorPane.scrollRectToVisible()
方法的一些代码示例,展示了JEditorPane.scrollRectToVisible()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JEditorPane.scrollRectToVisible()
方法的具体详情如下:
包路径:javax.swing.JEditorPane
类名称:JEditorPane
方法名:scrollRectToVisible
暂无
代码示例来源:origin: freeplane/freeplane
private void scrollUp() {
tip.scrollRectToVisible(new Rectangle(1, 1));
}
代码示例来源:origin: javax.help/javahelp
public void run() {
try {
Rectangle rec = html.modelToView(pos);
if (rec != null) {
html.scrollRectToVisible(rec);
}
} catch (BadLocationException bl) {
}
}
}
代码示例来源:origin: triplea-game/triplea
private static JList<String> newGameSelectionList(final DownloadFileDescription selectedMap,
final List<DownloadFileDescription> maps, final JEditorPane descriptionPanel,
final DefaultListModel<String> model) {
final JList<String> gamesList = new JList<>(model);
final int selectedIndex = maps.indexOf(selectedMap);
gamesList.setSelectedIndex(selectedIndex);
final String text = maps.get(selectedIndex).toHtmlString();
descriptionPanel.setText(text);
descriptionPanel.scrollRectToVisible(new Rectangle(0, 0, 0, 0));
return gamesList;
}
代码示例来源:origin: triplea-game/triplea
private static ListSelectionListener newDescriptionPanelUpdatingSelectionListener(
final JEditorPane descriptionPanel,
final JList<String> gamesList, final List<DownloadFileDescription> maps, final MapAction action,
final JLabel mapSizeLabelToUpdate) {
return e -> {
if (!e.getValueIsAdjusting()) {
final int index = gamesList.getSelectedIndex();
final boolean somethingIsSelected = index >= 0;
if (somethingIsSelected) {
final String mapName = gamesList.getModel().getElementAt(index);
// find the map description by map name and update the map download detail panel
final Optional<DownloadFileDescription> map =
maps.stream().filter(mapDescription -> mapDescription.getMapName().equals(mapName)).findFirst();
if (map.isPresent()) {
final String text = map.get().toHtmlString();
descriptionPanel.setText(text);
descriptionPanel.scrollRectToVisible(new Rectangle(0, 0, 0, 0));
updateMapUrlAndSizeLabel(map.get(), action, mapSizeLabelToUpdate);
}
}
}
};
}
代码示例来源: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-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.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: RPTools/maptool
public void componentResized(ComponentEvent e) {
// Jump to the bottom on new text
if (!MapTool.getFrame().getCommandPanel().getScrollLockButton().isSelected()) {
Rectangle rowBounds = new Rectangle(0, textPane.getSize().height, 1, 1);
textPane.scrollRectToVisible(rowBounds);
}
}
代码示例来源:origin: triplea-game/triplea
private void updateInfoPanel() {
if (getSelected() != null) {
final GameData data = getSelected().getGameData();
final StringBuilder notes = new StringBuilder();
notes.append("<h1>").append(data.getGameName()).append("</h1>");
final String mapNameDir = data.getProperties().get("mapName", "");
appendListItem("Map Name", mapNameDir, notes);
appendListItem("Number Of Players", data.getPlayerList().size() + "", notes);
appendListItem("Location", getSelected().getLocation() + "", notes);
appendListItem("Version", data.getGameVersion() + "", notes);
notes.append("<p></p>");
final String notesProperty = data.getProperties().get("notes", "");
if (notesProperty != null && notesProperty.trim().length() != 0) {
// AbstractUiContext resource loader should be null (or potentially is still the last game we played's loader),
// so we send the map dir name so that our localizing of image links can get a new resource loader if needed
notes.append(LocalizeHtml.localizeImgLinksInHtml(notesProperty.trim(), null, mapNameDir));
}
notesPanel.setText(notes.toString());
} else {
notesPanel.setText("");
}
// scroll to the top of the notes screen
SwingUtilities.invokeLater(() -> notesPanel.scrollRectToVisible(new Rectangle(0, 0, 0, 0)));
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-debugger-common2
editorPane.scrollRectToVisible(xBubble);
代码示例来源:origin: org.netbeans.api/org-netbeans-modules-languages
public void run() {
Iterator it = TopComponent.getRegistry ().getOpened ().iterator ();
while (it.hasNext ()) {
TopComponent tc = (TopComponent) it.next ();
EditorCookie ec = tc.getLookup ().lookup (EditorCookie.class);
if (ec == null) continue;
JEditorPane[] eps = ec.getOpenedPanes ();
if (eps == null) continue;
int i, k = eps.length;
for (i = 0; i < k; i++) {
if (eps [i].getDocument () == doc) {
final JEditorPane ep = eps [i];
if (ep != null)
try {
ep.scrollRectToVisible (ep.modelToView (offset));
} catch (BadLocationException ex) {
ErrorManager.getDefault ().notify (ex);
}
}
}
}
}
});
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-editor
@Override
public void refreshPreview() {
JEditorPane jep = (JEditorPane) getPreviewComponent();
try {
int rm = previewPrefs.getInt(rightMargin, getDefaultAsInt(rightMargin));
jep.putClientProperty("TextLimitLine", rm); //NOI18N
}
catch( NumberFormatException e ) {
// Ignore it
}
jep.setIgnoreRepaint(true);
jep.setText(previewText);
final BaseDocument bd = (BaseDocument)jep.getDocument();
final FortranCodeStyle codeStyle = FortranCodeStyle.get(bd, previewPrefs);
codeStyle.setupLexerAttributes(bd);
bd.runAtomicAsUser(new Runnable() {
@Override
public void run() {
try {
new FortranReformatter(bd, codeStyle).reformat();
} catch (BadLocationException ex) {
Exceptions.printStackTrace(ex);
}
}
});
jep.setIgnoreRepaint(false);
jep.scrollRectToVisible(new Rectangle(0,0,10,10) );
jep.repaint(100);
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-editor
pane.scrollRectToVisible(visibleRectangle);
pane.repaint(100);
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-ruby
jep.scrollRectToVisible(new Rectangle(0,0,10,10) );
jep.repaint(100);
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-editor
refreshPreview(previewPane, p);
previewPane.setIgnoreRepaint(false);
previewPane.scrollRectToVisible(new Rectangle(0,0,10,10) );
previewPane.repaint(100);
内容来源于网络,如有侵权,请联系作者删除!