private void VolumeCheckBoxActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_VolumeCheckBoxActionPerformed // if user de-select volume of size if (!VolumeCheckBox.isSelected()) { // select the detail checkbox DetailSizeCheckBox.setSelected(true); // disable the volume text field VolumeTF.setEnabled(false); VolumeTF.setText(""); VolumeLabel.setText("Volume : "); // reenable the detail of size text field LengthTF.setEnabled(true); LengthLabel.setText("* Length : "); WidthTF.setEnabled(true); WidthLabel.setText("* Width : "); HeightTF.setEnabled(true); HeightLabel.setText("* Height : "); } else { // dis-select the detail checkbox DetailSizeCheckBox.setSelected(false); // empty the detail text field and disable it LengthTF.setText(""); LengthTF.setEnabled(false); LengthLabel.setText("Length : "); WidthTF.setText(""); WidthTF.setEnabled(false); WidthLabel.setText("Width : "); HeightTF.setText(""); HeightTF.setEnabled(false); HeightLabel.setText("Height : "); // reenable volume text field VolumeTF.setEnabled(true); VolumeLabel.setText("* Volume : "); } } // GEN-LAST:event_VolumeCheckBoxActionPerformed
/** Creates new form AddSellerDialog */ public EditItemDialog(java.awt.Frame parent, boolean modal, JTable table, Connection conn) { super(parent, modal); this.conn = conn; initComponents(); GuiHelper.setOnCenter((Window) this); this.table = table; row = table.getSelectedRow(); item_code = (String) table.getModel().getValueAt(row, 0); // set data on dialog text field itemCodeTF.setText(item_code); nameTF.setText((String) table.getModel().getValueAt(row, 2)); categoryTF.setText((String) table.getModel().getValueAt(row, 1)); // just use plain number instead the currency format NumberFormat nf = NumberFormat.getCurrencyInstance(new Locale("id", "id")); try { buyingPriceTF.setText((nf.parse((String) table.getModel().getValueAt(row, 3))).toString()); salePriceTF.setText((nf.parse((String) table.getModel().getValueAt(row, 4))).toString()); } catch (java.text.ParseException pe) { pe.printStackTrace(); } commentTA.setText((String) table.getModel().getValueAt(row, 6)); // if length field is null, then deselect the detail size of checkbox if (((Integer) table.getModel().getValueAt(row, 8)).intValue() == 0) { DetailSizeCheckBoxActionPerformed(null); VolumeTF.setText(((Integer) table.getModel().getValueAt(row, 11)).toString()); } // if length, width, height field are not null, then deselect the volume checkbox else { VolumeCheckBoxActionPerformed(null); LengthTF.setText(((Integer) table.getModel().getValueAt(row, 8)).toString()); WidthTF.setText(((Integer) table.getModel().getValueAt(row, 9)).toString()); HeightTF.setText(((Integer) table.getModel().getValueAt(row, 10)).toString()); VolumeTF.setText(((Integer) table.getModel().getValueAt(row, 11)).toString()); } PrimaryTF.setText((String) table.getModel().getValueAt(row, 12)); MeasurementTF.setText(((Integer) table.getModel().getValueAt(row, 13)).toString()); SecondaryTF.setText((String) table.getModel().getValueAt(row, 14)); SecondaryThirdMeasurementTF.setText( ((Integer) table.getModel().getValueAt(row, 17)).toString()); ThirdTF.setText((String) table.getModel().getValueAt(row, 18)); producerdb = new ProducerDB(conn); producerdb.initializeComboBoxProducer(ProducerCoB); ProducerCoB.setSelectedItem((String) table.getModel().getValueAt(row, 15)); sellerdb = new SellerDB(conn); sellerdb.initializeSellerItem(listModel); sellerdb.initializeSuplierForItem( itemsellerModel, (String) table.getModel().getValueAt(row, 2)); sellerdb.harmonizeSellerItem(listModel, itemsellerModel); st = new InventoryDB(conn); st.initializeComboBox(WarehouseCB, "warehouse"); getRootPane().setDefaultButton(OK); itemindex = st.getItemIndex(item_code); // select warehousecombo box programmatically so quantity and expired date is set up WarehouseCB.setSelectedIndex(0); QuantityTB.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); }