Sharing a Document Between JTextComponents - Java Swing

Java examples for Swing:JTextComponent

Description

Sharing a Document Between JTextComponents

Demo Code

import javax.swing.JTextArea;
import javax.swing.text.JTextComponent;

public class Main {
  public static void main(String[] args) throws Exception {
    JTextComponent textComp1 = new JTextArea();
    JTextComponent textComp2 = new JTextArea();

    textComp2.setDocument(textComp1.getDocument());
  }// ww  w. j av  a  2  s. c o m

}

Related Tutorials