Currently im coding for a form which assigns resident to a specific unit for an apartment system. So now, im trying to figure out a validation that i can go with such as maybe for an example if user selects a specific unit no from the combo box to be assigned and click submit, the column selected by the user disappears or gets disabled. I need some assistance on this issue that im having. Is there a method of code i can use to create a validation for the unit no combo box?

combo box for assigning unit

  String fullname = fnameTxt.getText(); // check back your declaration for combobox 
    String block = (String) blockCbo.getSelectedItem();
    String floor = (String) floorCbo.getSelectedItem();
    String unit = (String) unitCbo.getSelectedItem();
    boolean isFound = false;

     if  ("".equals(fullname)) // check back your validation for this 
  {
        JOptionPane.showMessageDialog(null,"Resident's Full Name Is Mandatory.");
    }
      else  if (blockCbo.equals("NONE"))
  {
        JOptionPane.showMessageDialog(null,"Please Select A Block.");
    } 
      else  if (floorCbo.equals("NONE"))
  {
        JOptionPane.showMessageDialog(null,"Please Select A Floor Number.");
    } 
      else  if (unitCbo.equals("NONE"))
  {
        JOptionPane.showMessageDialog(null,"Please Select A Unit Number.");
    } 

     else {
        File file = new File("ResidentUnitDetails.txt");
        residentunit res = new residentunit(fullname, block, floor, unit);

        try (PrintWriter pw = new PrintWriter(new FileWriter(file, true))) {
            pw.println(res.toString());
            JOptionPane.showMessageDialog(this, "Resident Information Has Been Stored Successfully.");
             // enter validation for removing/disabling user selected combobox field
        } catch (IOException ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());
        }
    }

}                                         

0 Answers