开发者

Re-populating a JList on an ActionListener event

开发者 https://www.devze.com 2023-01-05 07:21 出处:网络
Depending on what they choose in the JComboBox I want the JList to show different strings, not sure how to repopulate a JList though. When searching through the API, still fou开发者_运维问答nd nothing

Depending on what they choose in the JComboBox I want the JList to show different strings, not sure how to repopulate a JList though. When searching through the API, still fou开发者_运维问答nd nothing.

Any idea on how you might code this?

Im using NetBeans by the way for reference.


The setListData() method allows you to reset the contents of the list.


not sure how to repopulate a JList though

DefaultListModel model = new DefaultListModel(...);
// add items to the model
list.setModel( model );

Or you could use the DefaultComboBoxModel which would allow you to create with model with a Vector or Array.

0

精彩评论

暂无评论...
验证码 换一张
取 消