@Override public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { background.getTableCellRendererComponent(table, null, isSelected, hasFocus, row, column); setBackground(background.getBackground()); value = table.getValueAt(row, 0); if (value instanceof CompanionFacade) { button.setText(LanguageBundle.getString("in_companionRemove")); // $NON-NLS-1$ } else { button.setText(LanguageBundle.getString("in_companionCreateNew")); // $NON-NLS-1$ } value = table.getValueAt(row, 1); if (value instanceof Boolean) { button.setEnabled((Boolean) value); } else { button.setEnabled(true); } return this; }
private void initComponents() { setTitle(LanguageBundle.getString("in_companionSelectRace")); // $NON-NLS-1$ setLayout(new BorderLayout()); Container container = getContentPane(); { final ListSelectionModel selectionModel = raceTable.getSelectionModel(); selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); selectionModel.addListSelectionListener( new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { selectButton.setEnabled(!selectionModel.isSelectionEmpty()); } } }); } SearchFilterPanel searchBar = new SearchFilterPanel(); container.add(searchBar, BorderLayout.NORTH); raceTable.setDisplayableFilter(searchBar); raceTable.addActionListener(this); raceTable.setTreeViewModel(this); container.add(new JScrollPane(raceTable), BorderLayout.CENTER); JPanel buttonPane = new JPanel(new FlowLayout()); selectButton.addActionListener(this); selectButton.setEnabled(false); selectButton.setActionCommand("SELECT"); buttonPane.add(selectButton); JButton cancelButton = new JButton(LanguageBundle.getString("in_cancel")); cancelButton.addActionListener(this); cancelButton.setActionCommand("CANCEL"); buttonPane.add(cancelButton); container.add(buttonPane, BorderLayout.SOUTH); Utility.installEscapeCloseOperation(this); }