public void paint(Graphics g) {
   Graphics2D g2 = (Graphics2D) g;
   bg.paintIcon(this, g2, 0, 0);
   TreeMap<Integer, FactoryObject> to = (TreeMap<Integer, FactoryObject>) fos.clone();
   for (Integer i : to.keySet()) {
     FactoryObject t = to.get(i);
     if (t.getIsLine()) {
       g2.setColor(Color.WHITE);
       g2.drawLine(t.getPositionX(), t.getPositionY(), t.getPositionXF(), t.getPositionYF());
     } else {
       if (t.getImageIndex() >= 0) {
         ImageIcon tmp = images.getIcon(t.getImageIndex());
         tmp.paintIcon(this, g2, t.getPositionX(), t.getPositionY());
       }
     }
   }
 }
  private void buildKitData(Kits selectedKit) {
    final int ST_SPACE = 25;
    kitDataPanel.removeAll();
    Box container = Box.createVerticalBox();
    setComponentSize(container, 400, PAGE_HEIGHT);
    JLabel kitID = new JLabel(Integer.toString(selectedKit.getKitID()));
    JLabel kitName = new JLabel(selectedKit.getName());
    JLabel kitDesc = new JLabel(selectedKit.getDescription());
    JLabel lp = new JLabel("----- Listed Parts -----");

    // align elements to the left collum
    // all the arguments can be left as KitID.LEFT because we only need any instance of a JComponent
    // to use the LEFT keyword
    kitID.setHorizontalAlignment(kitID.LEFT);
    kitName.setHorizontalAlignment(kitID.LEFT);
    kitDesc.setHorizontalAlignment(kitID.LEFT);
    lp.setHorizontalAlignment(kitID.LEFT);

    // add elements to container
    container.add(kitID);
    container.add(kitName);
    container.add(kitDesc);
    container.add(Box.createVerticalStrut(ST_SPACE));
    container.add(lp);

    // add part data
    TreeMap<Integer, Parts> kitParts = selectedKit.getListOfParts();
    for (Integer i : kitParts.keySet()) {
      Parts selectedPart = kitParts.get(i);
      Box holder = Box.createHorizontalBox();
      Box section1 = Box.createVerticalBox();
      Box section2 = Box.createVerticalBox();
      int imageIndex = selectedPart.getImageIndex();
      String PID = Integer.toString(selectedPart.getPartNumber());
      String PName = selectedPart.getName();
      String PDesc = selectedPart.getDesc();

      setComponentSize(holder, 400, 60);

      // add elements to section1
      section1.add(new JLabel("Part " + i));
      section1.add(new JLabel(images.getIcon(imageIndex - 1)));

      // add elements to section2
      section2.add(new JLabel("Part #: " + PID));
      section2.add(new JLabel("Part name: " + PName));
      section2.add(new JLabel("Part desc: " + PDesc));

      // add sections to holder
      holder.add(section1);
      holder.add(Box.createHorizontalStrut(ST_SPACE));
      holder.add(section2);

      // add holder to container
      container.add(holder);
    }

    // add the build items to the container
    buildQuantity = new JTextField("Enter number of kits to build");
    build = new JButton("Add to build queue");
    setComponentSize(buildQuantity, 400, 20);
    setComponentSize(buildQuantity, 400, 20);
    build.addActionListener(this);
    container.add(buildQuantity);
    container.add(build);

    // add container to kitDataPanel
    kitDataPanel.add(container);
    kitDataPanel.revalidate();
  }