Java Swing Tutorial - Java JEditorPane.setText(String t)








Syntax

JEditorPane.setText(String t) has the following syntax.

public void setText(String t)

Example

In the following code shows how to use JEditorPane.setText(String t) method.

/*from  w w w . j a va  2  s . c o m*/
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);

    JEditorPane editorPane = new JEditorPane();
    editorPane.setText("asdf");


    JScrollPane scrollPane = new JScrollPane(editorPane);
    frame.add(scrollPane);

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

}