+ private void addItem(final int item) {
+ JPanel minusPanel = new JPanel(new BorderLayout());
+ itemFields.put(item, minusPanel);
+
+ JComponent field = createField(item);
+
+ final JButton remove = new JButton();
+ setImage(remove, img64remove, "-");
+
+ remove.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ removeItem(item);
+ }
+ });
+
+ minusPanel.add(field, BorderLayout.CENTER);
+ minusPanel.add(remove, BorderLayout.EAST);
+
+ main.add(minusPanel);
+ main.revalidate();
+ main.repaint();
+ }
+
+ private void removeItem(int item) {
+ int last = itemFields.size() - 1;
+
+ for (int i = item; i <= last; i++) {
+ Object value = null;
+ if (i < last) {
+ value = getFromField(i + 1);
+ }
+ setToField(value, i);
+ setToInfo(value, i);
+ setDirtyItem(i);
+ }
+
+ main.remove(itemFields.remove(last));
+ main.revalidate();
+ main.repaint();
+ }
+