0

This is a snippet from a JCheckBox list. I need to capture events of items checked . As of now it is only selecting list code which is highlighted

private class ControlPanel extends JPanel {

    public ControlPanel() {
        this.add(new JLabel("Selection:"));
        this.add(new JButton(new SelectionAction("Clear", false)));
        this.add(new JButton(new SelectionAction("Check", true)));
    }
}

private class SelectionAction extends AbstractAction {

    boolean value;

    public SelectionAction(String name, boolean value) {
        super(name);
        this.value = value;
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        for (int i = 0; i < dataModel.getRowCount(); i++) {
            if (selectionModel.isSelectedIndex(i)) {
                dataModel.setValueAt(value, i, CHECK_COL);
            }
        }
    }
}
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Alfaromeo
  • 379
  • 2
  • 6
  • 14

0 Answers0