productsList.setCellRenderer(new ProductListCellRenderer()); productsList.getCheckBoxListSelectionModel().addListSelectionListener(new ListSelectionListener() {
productsList.setCellRenderer(new ProductListCellRenderer()); productsList.getCheckBoxListSelectionModel().addListSelectionListener(new ListSelectionListener() {
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)); }