I have a JTextArea. Suppose a user adds 5 lines of text into it. I want to add store each line as its own string in an Array of strings once my buttonClicked method is called. Any ideas of how to go about this?
This code will take the text inside of your JTextArea
called area
, split it by each new line, and then store each of those lines into an array called array
.
final String[] array = area.getText().split("\n");