Reputation: 81
I had a lecture today and I literally wrote what the teacher did, but the code just gives me an error saying:
java: incompatible types: int cannot be converted javax.swing.ListSelectionModel
This is the code that is faulty:
JList<String> list = new JList<>(listModel);
/*
...
*/
list.setSelectionModel(ListSelectionModel.SINGLE_SELECTION);
Upvotes: 0
Views: 300
Reputation: 458
I believe your teacher wrote:
JList<String> list = new JList<>(listModel);
/*
...
*/
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
//note how the methods name is supposed to end with Mode, not Model
Upvotes: 5