// -------------------------------------------------------------------------------------- // // ---------------------------------- Constructor Helpers ------------------------------- // // -------------------------------------------------------------------------------------- // private void buildActiveKits(JPanel container) { // initialize variable final int WIDTH = 150; // set containment panel properties container.setLayout(new BoxLayout(container, BoxLayout.Y_AXIS)); setComponentSize(container, 150, PAGE_HEIGHT); JLabel header = new JLabel("Active Kits"); header.setHorizontalAlignment(header.CENTER); header.setFont(new Font("Serif", Font.BOLD, 18)); setComponentSize(header, WIDTH, 25); // create list model and list listModel = new DefaultListModel(); kitList = new JList(listModel); kitList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); kitList.addListSelectionListener(this); kitList.setFixedCellHeight(25); JScrollPane listScrollPane = new JScrollPane(kitList); // add elements to containment panel container.add(header); container.add(listScrollPane); }
public void actionPerformed(ActionEvent ae) { try { String sbuildQuantity = buildQuantity.getText(); System.out.println(sbuildQuantity); int buildNumber = Integer.parseInt(sbuildQuantity); if (buildNumber <= 0) { System.out.println("Invalid kit build amount"); } else { Kits selectedKit = (Kits) kitList.getSelectedValue(); selectedKit.setBuildNumber(buildNumber); buildInfo.add(selectedKit); parent.syncBuildInfo(buildInfo); } } catch (Exception e) { System.out.println("Invalid kit build amount"); } }
public void valueChanged(ListSelectionEvent le) { if (!le.getValueIsAdjusting()) { Kits currentKit = (Kits) kitList.getSelectedValue(); if (currentKit != null) buildKitData(currentKit); } }