/** GUI element creating and arrangment. Partially generated using NetBeans IDE GUI utilities. */
  @SuppressWarnings("unchecked")
  private void initComponents() {
    jButtonOldPackages = new JButton();
    jTextDate = new JTextField();
    jButtonSetLost = new JButton();
    jButtonSetFound = new JButton();
    jButtonShowLost = new JButton();
    jButtonExit = new JButton();
    jButtonReset = new JButton();
    jScrollPane1 = new JScrollPane();
    jListScans = new JList();
    jScrollPane2 = new JScrollPane();
    jListPackages = new JList();

    jButtonSetFound.setEnabled(false);
    jButtonSetLost.setEnabled(false);

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

    jButtonOldPackages.setText("Timed out packages");
    jButtonOldPackages.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            buttonOldPackagesActionPerformed(event);
          }
        });

    ListSelectionListener listSelectionListener =
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent event) {
            jListPackagesActionPertformed(event);
          }
        };

    jButtonExit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            System.exit(0);
          }
        });

    jButtonSetLost.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            buttonSetLostActionPerformed(event);
          }
        });

    jButtonSetFound.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            buttonSetFoundActionPerformed(event);
          }
        });

    jButtonShowLost.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            buttonShowLostActionPerformed(event);
          }
        });

    jButtonReset.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            reset(event);
          }
        });

    jListPackages.addListSelectionListener(listSelectionListener);

    jButtonSetLost.setText("List as Lost");
    jButtonShowLost.setText("Lost Packages");
    jButtonSetFound.setText("List as Found");
    jButtonExit.setText("Logout");
    jButtonReset.setText("Reset");

    jScrollPane2.setViewportView(jListPackages);
    jScrollPane2.setPreferredSize(new Dimension(200, 200));
    jListPackages.setFixedCellWidth(400);

    jScrollPane1.setViewportView(jListScans);
    // Layout
    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(
                        jScrollPane2,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        300,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(111, 111, 111)
                    .addComponent(
                        jScrollPane1,
                        javax.swing.GroupLayout.PREFERRED_SIZE,
                        300,
                        javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(111, 111, 111)
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(
                                jTextDate,
                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                120,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(
                                jButtonSetLost, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(
                                jButtonOldPackages, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(
                                jButtonShowLost, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(
                                jButtonSetFound, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jButtonReset, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jButtonExit, javax.swing.GroupLayout.Alignment.TRAILING))
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    layout.setVerticalGroup(
        layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addGroup(
                        layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addGap(42, 42, 42)
                                    .addComponent(
                                        jTextDate,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jButtonOldPackages)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jButtonSetLost)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jButtonSetFound)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jButtonShowLost)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jButtonReset)
                                    .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jButtonExit))
                            .addGroup(
                                layout
                                    .createSequentialGroup()
                                    .addContainerGap()
                                    .addComponent(
                                        jScrollPane1,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        258,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(
                                jScrollPane2,
                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                289,
                                Short.MAX_VALUE))
                    .addContainerGap()));

    pack();
  }
    public ExampleField(ExampleOption option) {
      super(option);

      model = new DefaultListModel();
      model.addListDataListener(
          new ListDataListener() {
            @Override
            public void intervalAdded(ListDataEvent e) {
              fireChangeEvent();
            }

            @Override
            public void intervalRemoved(ListDataEvent e) {
              fireChangeEvent();
            }

            @Override
            public void contentsChanged(ListDataEvent e) {
              fireChangeEvent();
            }
          });

      final JList list =
          new JList(model) {
            @Override
            public Dimension getPreferredScrollableViewportSize() {
              return new Dimension(3 * CELL_SIZE, 2 * CELL_SIZE);
            }
          };
      list.setLayoutOrientation(JList.HORIZONTAL_WRAP);
      list.setVisibleRowCount(0);
      list.setFixedCellHeight(CELL_SIZE);
      list.setFixedCellWidth(CELL_SIZE);
      list.setTransferHandler(
          new URIImportTransferHandler() {
            @Override
            public boolean canImport(TransferSupport support) {
              support.setShowDropLocation(false);
              return super.canImport(support);
            }

            @Override
            public boolean importData(TransferSupport support) {
              try {
                List<BufferedImage> images = new ArrayList<BufferedImage>();
                for (URI u : getURIs(support)) {
                  try {
                    images.add(ImageIO.read(u.toURL()));
                  } catch (IOException e) {
                  }
                }
                addExamples(images);
                return true;
              } catch (IOException e) {
                return false;
              } catch (UnsupportedFlavorException e) {
                return false;
              } catch (URISyntaxException e) {
                return false;
              }
            }
          });
      list.setCellRenderer(
          new DefaultListCellRenderer() {
            @Override
            public Component getListCellRendererComponent(
                JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
              super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

              Example example = (Example) value;

              setHorizontalAlignment(SwingConstants.CENTER);
              setText(null);
              setIcon(example.getIcon());
              setBorder(BorderFactory.createEmptyBorder());

              return this;
            }
          });
      JScrollPane jsp = new JScrollPane(list);
      jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
      jsp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

      final JButton remove = new JButton("Remove");
      remove.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              int[] indices = list.getSelectedIndices();
              for (int i = indices.length - 1; i >= 0; i--) {
                model.remove(indices[i]);
              }
            }
          });
      list.addListSelectionListener(
          new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {
              remove.setEnabled(list.getSelectedIndex() != -1);
            }
          });
      remove.setEnabled(false);

      panel = new JPanel(new GridBagLayout());
      // Add list
      GridBagConstraints c = new GridBagConstraints();
      c.gridx = 0;
      c.gridy = 0;
      c.weightx = 1;
      c.weighty = 1;
      c.fill = GridBagConstraints.BOTH;
      panel.add(jsp, c);
      // Add remove button
      c = new GridBagConstraints();
      c.gridx = 0;
      c.anchor = GridBagConstraints.WEST;
      panel.add(remove, c);
    }