If this is a JTextArea component you can use the append method to add text to the end of the text area, or the insert method to insert the new text at a specific position.
If this is a JTextArea component you can use the . Append method to add text to the end of the text area, or the . Insert method to insert the new text at a specific position.
If you need to insert the text at the current cursor position use the (not-so-obviously-named) . GetCaretPosition method.
My problem is I want to insert text at the place where the cursor is placed in the textarea box and how do I get to know the exact place it is positioned in the textarea. – jerisalan Dec 1 at 23:38 Updated my answer. – normalocity Dec 1 at 23:49.
Check out: JTextComponent. GetCaretPosition(). The method getCaretPosition() is inherited by JTextArea, you can use it to get the cursor position.
Then you can use JTextArea. Insert(String str, int pos) to insert text at that position. Sample: JFrame frame = new JFrame(); frame.
SetLayout(new BorderLayout()); final JTextArea jta = new JTextArea(" world\n JButton btn = new JButton("Add"); btn. AddActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int pos = jta. GetCaretPosition(); //get the cursor position jta.
Insert("Some more", pos); //insert your text } }); frame. Add(jta, BorderLayout. CENTER); frame.
Add(btn, BorderLayout. SOUTH); frame. SetDefaultCloseOperation(JFrame.
EXIT_ON_CLOSE); frame.pack(); frame. SetVisible(true).
TextArea. ReplaceSelection(text); From the API: Replaces the currently selected content with new content represented by the given string. If there is no selection this amounts to an insert of the given text.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.