Example usage for javax.swing JScrollPane scrollRectToVisible

List of usage examples for javax.swing JScrollPane scrollRectToVisible

Introduction

In this page you can find the example usage for javax.swing JScrollPane scrollRectToVisible.

Prototype

public void scrollRectToVisible(Rectangle aRect) 

Source Link

Document

Forwards the scrollRectToVisible() message to the JComponent's parent.

Usage

From source file:com.evanbelcher.DrillBook.display.DBMenuBar.java

/**
 * Displays help window//from   ww w  .j av a2  s  . c  o  m
 */
private void help() {
    String msg = "";

    MutableDataSet options = new MutableDataSet();
    Parser parser = Parser.builder(options).build();
    HtmlRenderer renderer = HtmlRenderer.builder(options).build();

    try {
        msg = IOUtils.toString(Main.getFile("Usage.md", this));
        Node document = parser.parse(msg);
        msg = renderer.render(document);
    } catch (IOException e) {
        e.printStackTrace();
    }

    JTextPane area = new JTextPane();
    area.setContentType("text/html");
    area.setText(msg);
    area.setCaretPosition(0);
    area.setEditable(false);

    JScrollPane scrollPane = new JScrollPane(area);
    scrollPane
            .setMaximumSize(new Dimension(GraphicsRunner.SCREEN_SIZE.width, GraphicsRunner.SCREEN_SIZE.height));
    scrollPane.setPreferredSize(
            new Dimension(GraphicsRunner.SCREEN_SIZE.width - 10, GraphicsRunner.SCREEN_SIZE.height - 10));
    scrollPane.scrollRectToVisible(new Rectangle());
    JOptionPane.showMessageDialog(this, scrollPane, "Help", JOptionPane.PLAIN_MESSAGE);
}