Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
swdev:java:component:jlist [2017/09/29 16:31]
smayr created
swdev:java:component:jlist [2017/09/29 16:33] (current)
smayr
Line 1: Line 1:
 = JList = = JList =
  
-To programmatically populate the list models:+To programmatically populate the list models of a JList called ''lstNames'':
 <code java> <code java>
 +import javax.swing.DefaultListModel;
 +import javax.swing.JList;
 +//...
 +
     private void btnTestActionPerformed(java.awt.event.ActionEvent evt) {                                             private void btnTestActionPerformed(java.awt.event.ActionEvent evt) {                                        
         // TODO add your handling code here:         // TODO add your handling code here:
Line 15: Line 19:
         listModel.addElement("Kathy Green");         listModel.addElement("Kathy Green");
  
-        lstFiles.setModel(listModel);+        lstNames.setModel(listModel);
     }     }
 </code>     </code>