Java JTextPane scrollTo(JTextPane textPane, int position)

Here you can find the source of scrollTo(JTextPane textPane, int position)

Description

Forces a portion of the document to become visible.

License

Apache License

Declaration

public static void scrollTo(JTextPane textPane, int position)
        throws BadLocationException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.awt.Rectangle;

import javax.swing.JTextPane;

import javax.swing.text.BadLocationException;

public class Main {
    /**//from   w  ww .  j a v  a  2s .  c  o  m
     * Forces a portion of the document to become visible.
     */
    public static void scrollTo(JTextPane textPane, int position)
            throws BadLocationException {
        Rectangle r = textPane.modelToView(position);
        if (r != null) {
            textPane.scrollRectToVisible(r);
        }
    }
}

Related

  1. getForegroundColor(JTextPane textPane)
  2. insertStyledString(JTextPane textPane, String text, SimpleAttributeSet attrSet, Color background, Color foreground, String fontFamily, int fontSize, boolean bold, boolean italic, boolean underline, boolean strikeThrough, Boolean superscript)
  3. isSelectionBold(JTextPane textPane)
  4. overrideStyle(String styleName, JTextPane textPane, Style newStyle)
  5. saveFile(JTextPane txt)
  6. setDefaultTextPaneProperties(JTextPane textPane)
  7. setJTextPaneFont(JTextPane jtp, Font font, Color c)
  8. setSelectionFontSize(JTextPane textPane, int fontSize)
  9. setSelectionForeground(JTextPane textPane, Color color)