List of usage examples for com.jgoodies.binding.adapter BasicComponentFactory createList
public static <E> JList createList(SelectionInList<E> selectionInList, ListCellRenderer cellRenderer)
If the selectionInList's selection holder is a ComponentValueModel it is synchronized with the visible and enabled state of the returned list.
From source file:ch.fork.AdHocRailway.ui.turnouts.configuration.TurnoutConfigurationDialog.java
License:Open Source License
private void initComponents() { turnoutGroups = new ArrayListModel<TurnoutGroup>(); turnoutGroupModel = new SelectionInList<TurnoutGroup>((ListModel<?>) turnoutGroups); turnoutGroupList = BasicComponentFactory.createList(turnoutGroupModel, new TurnoutGroupListCellRenderer()); turnoutGroupList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); turnoutGroupList.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "deleteTurnoutGroup"); turnoutGroupList.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), "deleteTurnoutGroup"); turnoutGroupList.getActionMap().put("deleteTurnoutGroup", new RemoveTurnoutGroupAction()); groupScrollPane = new JScrollPane(turnoutGroupList); turnoutGroupConfig = new TurnoutGroupConfigPanel(); addGroupButton = new JButton(new AddTurnoutGroupAction()); editGroupButton = new JButton(new EditTurnoutGroupAction()); removeGroupButton = new JButton(new RemoveTurnoutGroupAction()); turnouts = new ArrayListModel<Turnout>(); turnoutModel = new SelectionInList<Turnout>(); turnoutModel.setList(turnouts);// w w w .j av a 2 s.c o m turnoutsTable = new JTable() { @Override public boolean getScrollableTracksViewportWidth() { return getPreferredSize().width < getParent().getWidth(); } }; turnoutsTable.setModel(new TurnoutTableModel(turnoutModel)); turnoutsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); turnoutsTable.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "deleteTurnout"); turnoutsTable.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), "deleteTurnout"); turnoutsTable.getActionMap().put("deleteTurnout", new RemoveTurnoutAction()); final TableColumn typeColumn = turnoutsTable.getColumnModel().getColumn(1); typeColumn.setCellRenderer(new TurnoutTypeCellRenderer()); final TableColumn defaultStateColumn = turnoutsTable.getColumnModel().getColumn(8); defaultStateColumn.setCellRenderer(new TurnoutDefaultStateCellRenderer()); turnoutsTable.setRowHeight(30); turnoutTableScrollPane = new JScrollPane(turnoutsTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); turnoutsTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); tca = new TableColumnAdjuster(turnoutsTable, 10); addTurnoutButton = new JButton(new AddTurnoutAction()); removeTurnoutButton = new JButton(new RemoveTurnoutAction()); okButton = new JButton("OK", ImageTools.createImageIconFromIconSet("dialog-ok-apply.png")); okButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { okPressed = true; setVisible(false); turnoutManager.removeTurnoutManagerListenerInNextEvent(TurnoutConfigurationDialog.this); } }); }