I use a JTextArea
in which I use setText
method to have some text while opening GUI.
Once text area is opened with the text I set, I typed some text, my intention is to get whatever text user types.
dataField = new JTextArea();
dataField.setText("sample#");
..
...
If I type "hello world"
sample#hello world
in text area and press enter I need to get only hello world in a string and not sample#hello world. I have tried with key listeners and appended the input characters to a string builder but backspace also creates a unreadable character an appends to it.
Simply put, I need to get user typed text from text area.