JButton[] () { final JButton addButton = new JButton(JavaCompilerBundle.message("button.add")); addButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e){ addPath(myDescriptor); } } ); myRemoveButton = new JButton(IdeBundle.message("button.remove")); myRemoveButton.addActionListener( new ActionListener(){ @Override public void actionPerformed(ActionEvent e){ removePaths(); } } ); myRemoveButton.setEnabled(false); myRemoveButton.getModel().addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (myExcludedTable.getSelectedRow() == -1) { myRemoveButton.setEnabled(false); } } }); return new JButton[]{/*addButton, myRemoveButton*/}; }