Example usage for javax.swing JTextArea setDocument

List of usage examples for javax.swing JTextArea setDocument

Introduction

In this page you can find the example usage for javax.swing JTextArea setDocument.

Prototype

@BeanProperty(expert = true, description = "the text document model")
public void setDocument(Document doc) 

Source Link

Document

Associates the editor with a text document.

Usage

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame("Shared Model");

    JTextArea areaFiftyOne = new JTextArea();
    JTextArea areaFiftyTwo = new JTextArea();
    areaFiftyTwo.setDocument(areaFiftyOne.getDocument());
    JTextArea areaFiftyThree = new JTextArea();
    areaFiftyThree.setDocument(areaFiftyOne.getDocument());

    frame.setLayout(new GridLayout(3, 1));
    frame.add(new JScrollPane(areaFiftyOne));
    frame.add(new JScrollPane(areaFiftyTwo));
    frame.add(new JScrollPane(areaFiftyThree));

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(300, 300);/*  ww  w  .  ja v  a  2s .co m*/
    frame.setVisible(true);
}