Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
根据他们在 JComboBox 中选择的内容,我希望 JList 显示不同的字符串,但不确定如何重新填充 JList。通过API搜索时,仍然一无所获。
关于如何编码的任何想法?
顺便说一下,我使用 NetBeans 以供参考。
该setListData()方法允许您重置列表的内容。
setListData()
不确定如何重新填充 JList
DefaultListModel model = new DefaultListModel(...); // add items to the model list.setModel( model );
或者您可以使用 DefaultComboBoxModel,它允许您使用带有向量或数组的模型创建。