I've looked for the answer to this on SO and elsewhere but can't find an answer. Is it possible to select an entire jlist rather than a specific item? For example if a user were to click on the white area of a jlist I could call a method which would put that jlist's name in a HashMap or call another method to alter the list as a whole. Hopefully the code gives you an idea. Any info would be helpful. Thanks.
final JList list_1 = new JList(list1);
list_1.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent arg0) {
//make entire list disappear when selected
list_1.setVisible(false);
}
});
GridBagConstraints gbc_list_1 = new GridBagConstraints();
gbc_list_1.gridheight = 3;
gbc_list_1.insets = new Insets(0, 0, 5, 5);
gbc_list_1.fill = GridBagConstraints.BOTH;
gbc_list_1.gridx = 5;
gbc_list_1.gridy = 0;
panel.add(list_1, gbc_list_1);