- Use a JTextArea to show multiple lines of text
- You can specify the number of rows and columns:
final int ROWS = 10;
final int COLUMNS = 30;
JTextArea textArea = new JTextArea(ROWS, COLUMNS);
- setText: to set the text of a text field or text area
- append: to add text to the end of a text area
- Use newline characters to separate lines:
textArea.append(account.getBalance() + "\n");
- To use for display purposes only:
textArea.setEditable(false); // program can call setText and append to change it