trackList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); trackPanel.setViewportView(trackList);
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)); }
/** * 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); } }