Java: JLabel for output

Why using JLabel for output is usually bad

It's possible to change the text of a JLabel, although this is not generally a good idea after the user interface is already displayed. For output JTextField is often a better choice. The use of JLabel for output is mentioned because some textbooks display output this way. Here are some reasons not to use it.

Changing the text of a JLabel

Most JLabels are never changed, except for internationalization, and that is done before the user interface is shown. To change the text, use

yourLabel.setText(String newText);  //