List of usage examples for javax.swing JTextArea getDocument
public Document getDocument()
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTextArea textarea1 = new JTextArea(); Document document = textarea1.getDocument(); JTextArea textarea2 = new JTextArea(document); JTextArea textarea3 = new JTextArea(document); frame.setLayout(new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS)); frame.add(new JScrollPane(textarea1)); frame.add(new JScrollPane(textarea2)); frame.add(new JScrollPane(textarea3)); frame.setSize(300, 400);/* w w w .java2 s. c o m*/ frame.setVisible(true); }
From source file:MainClass.java
public static void main(String args[]) { JFrame frame = new JFrame("Sharing Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container content = frame.getContentPane(); JTextArea textarea1 = new JTextArea(); Document document = textarea1.getDocument(); JTextArea textarea2 = new JTextArea(document); JTextArea textarea3 = new JTextArea(document); content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS)); content.add(new JScrollPane(textarea1)); content.add(new JScrollPane(textarea2)); content.add(new JScrollPane(textarea3)); frame.setSize(300, 400);/* w ww . j ava2s .c om*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { DocumentFilter dfilter = new UpperCaseFilter(); JTextArea jta = new JTextArea(); ((AbstractDocument) jta.getDocument()).setDocumentFilter(dfilter); JFrame frame = new JFrame("UpcaseFilter"); frame.getContentPane().add(jta, java.awt.BorderLayout.CENTER); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(200, 120);/* w ww .j a va 2 s.c om*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTextArea textArea = new JTextArea("word1 word2\nword3\nword4"); Element paragraph = textArea.getDocument().getDefaultRootElement(); int contentCount = paragraph.getElementCount(); for (int i = 0; i < contentCount; i++) { Element e = paragraph.getElement(i); int rangeStart = e.getStartOffset(); int rangeEnd = e.getEndOffset(); String line = textArea.getText(rangeStart, rangeEnd - rangeStart); System.out.println(line); }/* w w w . j a va 2 s . c o m*/ }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTextArea textArea = new JTextArea("word1 word2\nword3\nword4"); Document doc = textArea.getDocument(); ElementIterator it = new ElementIterator(doc.getDefaultRootElement()); Element e;//from w w w . j a v a 2 s . c om while ((e = it.next()) != null) { if (e.isLeaf()) { int rangeStart = e.getStartOffset(); int rangeEnd = e.getEndOffset(); String line = textArea.getText(rangeStart, rangeEnd - rangeStart); System.out.println(line); } } }
From source file:Main.java
public static void main(String[] args) { JTextArea ta = new JTextArea(20, 20); ((AbstractDocument) ta.getDocument()).setDocumentFilter(new MyFilter()); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new BorderLayout()); frame.add(new JScrollPane(ta)); frame.pack();//from www . j a va 2 s .co m frame.setVisible(true); }
From source file:UpcaseFilter.java
public static void main(String[] args) { DocumentFilter dfilter = new UpcaseFilter(); JTextArea jta = new JTextArea(); JTextField jtf = new JTextField(); ((AbstractDocument) jta.getDocument()).setDocumentFilter(dfilter); ((AbstractDocument) jtf.getDocument()).setDocumentFilter(dfilter); JFrame frame = new JFrame("UpcaseFilter"); frame.getContentPane().add(jta, java.awt.BorderLayout.CENTER); frame.getContentPane().add(jtf, java.awt.BorderLayout.SOUTH); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(200, 120);//from w w w . j a va 2 s. c om frame.setVisible(true); }
From source file:UpcaseFilter.java
public static void main(String[] args) { DocumentFilter dfilter = new UpcaseFilter(); JTextArea jta = new JTextArea(); JTextField jtf = new JTextField(); ((AbstractDocument) jta.getDocument()).setDocumentFilter(dfilter); ((AbstractDocument) jtf.getDocument()).setDocumentFilter(dfilter); JFrame frame = new JFrame("UpcaseFilter"); frame.getContentPane().add(jta, "Center"); frame.getContentPane().add(jtf, "South"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(200, 120);//w ww. j ava 2s.c o m frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JTextArea textArea = new JTextArea(10, 30); AbstractDocument doc = (AbstractDocument) textArea.getDocument(); doc.setDocumentFilter(new EndOfLineFilter()); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JScrollPane(textArea)); frame.pack();/*from w w w . j ava2s . c om*/ frame.setVisible(true); }
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);// www .j a v a2s . co m frame.setVisible(true); }