filterableList.getCheckBoxListSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) {
private void updatePane() { variableList.getCheckBoxListSelectionModel().removeListSelectionListener(checkBoxSelectionListener); variableList.setModel(model); variableList.setCheckBoxListSelectedIndices(getSelectedIndices(model)); final CheckBoxListSelectionModel selectionModel = variableList.getCheckBoxListSelectionModel(); selectionModel.addListSelectionListener(checkBoxSelectionListener); }
checkBoxList.getCheckBoxListSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) {
productsList.getCheckBoxListSelectionModel().addListSelectionListener(new ListSelectionListener() {
productsList.getCheckBoxListSelectionModel().addListSelectionListener(new ListSelectionListener() {
maskNameList.getCheckBoxListSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) {
filterableList.getCheckBoxListSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) {
BorderFactory.createEmptyBorder(6, 0, 0, 0))); selectedPanel.add(new JScrollPane(selectedList)); _list.getCheckBoxListSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) {
maskNameList.getCheckBoxListSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) {
protected void toggleSelection(int index) { if (!_list.isEnabled() || !_list.isCheckBoxEnabled(index)) { return; } CheckBoxListSelectionModel selectionModel = _list.getCheckBoxListSelectionModel(); boolean selected = selectionModel.isSelectedIndex(index); selectionModel.removeListSelectionListener(this); try { if (selected) selectionModel.removeSelectionInterval(index, index); else selectionModel.addSelectionInterval(index, index); } finally { selectionModel.addListSelectionListener(this); _list.repaint(); } }
/** * Initialize the CheckBoxList. */ protected void init() { _checkBoxListSelectionModel = createCheckBoxListSelectionModel(getModel()); setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); _listCellRenderer = createCellRenderer(); _handler = createHandler(); _checkBoxListSelectionModel.addListSelectionListener(_handler); JideSwingUtilities.insertMouseListener(this, _handler, 0); JideSwingUtilities.insertMouseMotionListener(this, _handler, 0); addKeyListener(_handler); addPropertyChangeListener("model", _handler); ListModel model = getModel(); if (model != null) { model.addListDataListener(_handler); } }
private void createPane() { final TableLayout tableLayout = new TableLayout(1); tableLayout.setTableAnchor(TableLayout.Anchor.NORTHWEST); tableLayout.setTableFill(TableLayout.Fill.BOTH); tableLayout.setTablePadding(4, 4); tableLayout.setTableWeightY(1.0); tableLayout.setTableWeightX(1.0); setLayout(tableLayout); variableList = new CheckBoxList(model); variableList.setCellRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value instanceof Variable) { Variable variable = (Variable) value; label.setText(variable.getName()); } return label; } }); variableList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); checkBoxSelectionListener = new CheckBoxSelectionListener(variableList); variableList.getCheckBoxListSelectionModel().addListSelectionListener(checkBoxSelectionListener); add(new JScrollPane(variableList)); }
protected void toggleSelections() { int[] indices = _list.getSelectedIndices(); CheckBoxListSelectionModel selectionModel = _list.getCheckBoxListSelectionModel(); selectionModel.removeListSelectionListener(this); selectionModel.setValueIsAdjusting(true); try { if (indices.length > 0) { boolean selected = selectionModel.isSelectedIndex(indices[0]); for (int index : indices) { if (!_list.isCheckBoxEnabled(index)) { continue; } if (selected && selectionModel.isSelectedIndex(index)) { selectionModel.removeSelectionInterval(index, index); } else if (!selected && !selectionModel.isSelectedIndex(index)) { selectionModel.addSelectionInterval(index, index); } } } } finally { selectionModel.setValueIsAdjusting(false); selectionModel.addListSelectionListener(this); _list.repaint(); } }