I need help populating the Jlist correctly. When I press the >> button it should add the selected part from the left panel to the list of parts in the right panel. The << button should delete the selected part from the right panel. Im pretty sure Im not using a method correctly.
//This Add_1 button adds the selected part from the left panel to the list of parts in the right panel.
Add_1.addActionListener(new ActionListener() {
@SuppressWaings("unused")
public void actionPerformed(java.awt.event.ActionEvent evt) {
DefaultListModel model1 = new DefaultListModel();
for(int i = 0; i < list.getModel().getSize(); i++)
{
Object item = list.getModel().getElementAt(i);
model1.addElement(item);
list_1.setModel(model1);
}
}
});
enter image description here //delete button
btnNewButton_1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
DefaultListModel model2 = new DefaultListModel();
model2.addElement(list_1.getSelectedValue());
list.setModel(model2);
}
});
