我的 JList 模型方法给我一个错误
My JList model method gives me an error
我今天有一个讲座,我真的按照老师做的写了,但是代码给我一个错误说:
java: incompatible types: int cannot be converted javax.swing.ListSelectionModel
这是错误的代码:
JList<String> list = new JList<>(listModel);
/*
...
*/
list.setSelectionModel(ListSelectionModel.SINGLE_SELECTION);
我相信你的老师写道:
JList<String> list = new JList<>(listModel);
/*
...
*/
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
//note how the methods name is supposed to end with Mode, not Model
我今天有一个讲座,我真的按照老师做的写了,但是代码给我一个错误说:
java: incompatible types: int cannot be converted javax.swing.ListSelectionModel
这是错误的代码:
JList<String> list = new JList<>(listModel);
/*
...
*/
list.setSelectionModel(ListSelectionModel.SINGLE_SELECTION);
我相信你的老师写道:
JList<String> list = new JList<>(listModel);
/*
...
*/
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
//note how the methods name is supposed to end with Mode, not Model