List of usage examples for javax.swing JTextArea insert
public void insert(String str, int pos)
From source file:Main.java
public static void main(String[] argv) { JTextArea ta = new JTextArea("Initial Text"); int pos = 5;// w w w. j a va2s . com ta.insert("some text", pos); }
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;//w w w . ja va2 s . co m ta.insert("some text", pos); }
From source file:com._17od.upm.gui.AccountDialog.java
/** * This method takes in a JTextArea object and then inserts the contents of * the system clipboard into that text area at the cursor position. * /*ww w . j a v a2s . co m*/ * @param textArea */ public void pasteToTextArea(JTextArea textArea) { String text = ""; Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); Transferable clipText = clipboard.getContents(null); if ((clipText != null) && clipText.isDataFlavorSupported(DataFlavor.stringFlavor)) { try { text = (String) clipText.getTransferData(DataFlavor.stringFlavor); } catch (UnsupportedFlavorException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } } textArea.insert(text, textArea.getCaretPosition()); textArea.requestFocus(); }