0
下面是我的代码:的HashMap到DefaultListModel
HashMap<String, String> inst1 = new HashMap(instructorIO.getInstructors());
instListModel = new DefaultListModel<String>(inst1.values());
我得到的错误:
DepartmentProject.java:69: error: constructor DefaultListModel in class DefaultListModel<E> cannot be applied to given types;
required: no arguments
found: Collection<String>
reason: actual and formal argument lists differ in length
where E is a type-variable:
E extends Object declared in class DefaultListModel
谁能帮助我?
'DefaultListModel'不带任何参数,你传递一个集合。 – 2012-02-28 00:16:56
有没有办法将hashmap中的每个值放入列表模型中? – cataschok 2012-02-28 00:20:00
你需要添加元素到'ListModel',所以通过你的'HashMap'循环,并将每个值添加到'ListModel' – 2012-02-28 00:24:02