i'm trying to extend the class CheckBoxListComboBox, so if someone opens the list and presses CTRL+A, then all of the items in the list gets selected:
i mean all of the items will have a blue background and all of the checkboxes gets selected like on the picture.
The functionality with the whitespace should not change: after pressing CTRL+A pressing the whitespace should select/deselect all of the items.
My try was the following code fragment, but this doesn't even reacts to CTRL+A:
- Code: Select all
String[] _content = new String[]{"One", "Two", "Three", "Four", "Five"};
Action action = new AbstractAction("selectall") {
private static final long serialVersionUID = 1L;
@Override public void actionPerformed(ActionEvent evt) {
System.out.format("\n-->CBoxListComboBox: selecting all...\n");
setSelectedObjects(_content);
}
};
String key = "select_all";
this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_DOWN_MASK), key);
this.getActionMap().put(key, action);
Can you help me to implement this?
Thanx in advance,
Daniel