@Override public void execute(ActionEvent e) { ApplicationContext ctx = AppContext.getContext(); final ApplicationWindow win = ctx.getBean(ApplicationWindow.class); final String title = resources.getResourceByKey("SetLayerColorCommand.dialog.subtitle"); final LayerTableModel model = AppContext.getContext().getBean(ShowLayersCommand.class).getLayerPanel().getLayerModel(); AlternatingLineTable layerTable = AppContext.getContext().getBean(ShowLayersCommand.class).getLayerPanel().getLayerTable(); int index = layerTable.convertRowIndexToModel(layerTable.getSelectedRow()); if (index >= 0) { layer = model.getLayer().get(index); } if (layer == null) { return; } final JColorChooser chooser = new JColorChooser(); ActionListener okListener = new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { dialog.setVisible(false); layer.setColor(chooser.getColor()); model.fireTableDataChanged(); EditorUtils.getCurrentActiveEditor().setFileState(FileState.DIRTY); } }; ActionListener cancelListener = new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { dialog.setVisible(false); } }; dialog = JColorChooser.createDialog(win, title, true, chooser, okListener, cancelListener); dialog.setVisible(true); }