List of usage examples for javax.swing JTextArea JTextArea
public JTextArea(Document doc)
From source file:Main.java
public static void main(String[] argv) { JTextArea ta = new JTextArea("Initial Text"); ta.append("some text"); }
From source file:Main.java
public static void main(String[] argv) { JTextArea ta = new JTextArea("Initial Text"); int pos = 5;//from ww w .j av a 2 s. c o m ta.insert("some text", pos); }
From source file:Main.java
public static void main(String[] argv) { JTextArea ta = new JTextArea("Initial Text"); int start = 0; int end = 3;/*from w w w. j ava2 s .co m*/ ta.replaceRange("new text", start, end); }
From source file:Main.java
public static void main(String[] argv) { JTextArea ta = new JTextArea("Initial Text"); int start = 0; int end = 5;// www . ja v a 2 s. c o m ta.replaceRange(null, start, end); }
From source file:Main.java
public static void main(String[] argv) { // Create the text area JTextArea ta = new JTextArea("Initial Text"); // Insert some text at the beginning int pos = 0;/*from w w w. j a v a 2 s.co m*/ ta.insert("some text", pos); }
From source file:Main.java
public static void main(String[] argv) { // Create a text area with some initial text JTextArea textarea = new JTextArea("Initial Text"); int rows = 20; int cols = 30; textarea = new JTextArea("Initial Text", rows, cols); }
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); }/*from w ww. jav a2 s . co m*/ }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTextComponent tc = new JTextArea("Initial Text"); int docLength = tc.getDocument().getLength(); String text = tc.getText();/*from www . ja v a2 s . c o m*/ // Get the last 3 characters int offset = docLength - 3; int len = 3; text = tc.getText(offset, len); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTextComponent tc = new JTextArea("Initial Text"); int docLength = tc.getDocument().getLength(); // Get all text String text = tc.getText();//www. j av a 2 s .c o m // Get the first 3 characters int offset = 0; int len = 3; text = tc.getText(offset, len); }
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;//ww w. j a v a 2 s . co m 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); } } }