If using Netbeans, place the component and then edit the Model in the Properties with user code to include the listModel that we created earlier in the class.
So...
listModel = new DefaultListModel();
We can populate this at any time with:
listModel.addElement(“item 1”);
listModel.addElement(“item 2”);
The constructor for the jList must include the model, similar to:
JListjList1 = new JList(listModel);
listModel.addElement(“new item”)
No comments:
Post a Comment
Note: only a member of this blog may post a comment.