'Changing a String array for a JComboBox depending on another value in another ComboBox

I'm trying to create a Combobox, where, when a value is changed in the first Combobox, in this case which is "FlightNumber", to change the String array in another Combobox in the same window, which is "Baggage" depending on which value is selected in the FlightNumber Combobox.

Every time I try to do this, the program hangs after selecting a Flight number from the drop down menu.

 private void jComboBox_flightNumberActionPerformed(java.awt.event.ActionEvent evt) {
    int number = Integer.parseInt((String)jComboBox_flightNumber.getSelectedItem());
    boolean found = false;
    int baggageSize = 0;
    int counter;
    System.out.println(this.flightList.size());
    System.out.println(number);
    for(counter = 0; counter < this.flightList.size() || !found; counter++){
        Flight flight = this.flightList.get(counter);
        if(flight.getFlightID() == number) { 
            found = true;
            baggageSize = flight.getBaggage();
            System.out.println(baggageSize);
        }else{
        found = false;
        }
    }
    
     String [] baggageLength = new String[baggageSize];
    for(int x = 0;counter < baggageLength.length; x++) { 
        baggageLength[counter] = Integer.toString((x+1));

    }
    
    this.baggageSize = baggageLength;
    
    jComboBox_baggage.setModel(new javax.swing.DefaultComboBoxModel<>(this.baggageSize));
    jComboBox_baggage.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jComboBox_baggageActionPerformed(evt);
        }
    });
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source