add.setBounds(150,125,60,20);
remove.setBounds(209,125,80,20);
add.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
editor.addEmitter(new ConfigurableEmitter("NewEmitter_"+System.currentTimeMillis()));
}
});
remove.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ConfigurableEmitter emitter = (ConfigurableEmitter) list.getSelectedValue();
if (emitter != null) {
editor.removeEmitter(emitter);
}
}
});
list.setCellRenderer(new Renderer());
list.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
int index = list.locationToIndex(e.getPoint());
if (index != -1) {
if (list.getCellBounds(index, index).contains(e.getPoint())) {
if (lastSelect == list.getSelectedIndex()) {
ConfigurableEmitter emitter = (ConfigurableEmitter) list.getModel().getElementAt(index);
JCheckBox box = (JCheckBox) checks.get(emitter);
emitter.setEnabled(!emitter.isEnabled());
box.setSelected(emitter.isEnabled());
repaint();
} else {
lastSelect = list.getSelectedIndex();
}