Java Swing Tutorial - Java JEditorPane .getScrollable Tracks Viewport Width ()








Syntax

JEditorPane.getScrollableTracksViewportWidth() has the following syntax.

public boolean getScrollableTracksViewportWidth()

Example

In the following code shows how to use JEditorPane.getScrollableTracksViewportWidth() method.

/*ww w.  ja  va 2  s.co m*/

import java.awt.Dimension;
import java.io.IOException;

import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;

public class Main {

  public static void main(final String args[]) {
    JFrame frame = new JFrame("EditorPane Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    try {
      JEditorPane editorPane = new JEditorPane("http://www.java2s.com");
      editorPane.setEditable(false);
      boolean b =  editorPane.getScrollableTracksViewportWidth();

      JScrollPane scrollPane = new JScrollPane(editorPane);
      frame.add(scrollPane);
    } catch (IOException e) {
      System.err.println("Unable to load: " + e);
    }

    frame.setSize(640, 480);
    frame.setVisible(true);
  }

}