As the title says, I have a JList on the left side and a JTextArea on the right.
I set my listener for JList in the makeTextPanel () method as follows:
listSelectionModel = list.getSelectionModel();
listSelectionModel.addListSelectionListener(this);
where is the method called in the action event:
public void valueChanged(ListSelectionEvent e) {
System.out.println("HEY");
textArea.setText(null);
textArea.setText("1: \n");
textArea.append("2: \n");
textArea.append("3: \n");
textArea.append("4: \n");
}
The event occurs because in the terminal I see "HEY", but nothing is printed in the text box. If I try to print a text field in the makeTextPanel () method after creating the text field, it will be printed. What's wrong? Why not print valueChanged events in the method? I would really appreciate it if someone could take a look at what I don't see here.
Full code:
source
share