Here's the thing...

I have 2 GUI programs.  

A Menu Program,which is basically a frame with buttons of food items,the buttons when clicked
opens this other program,an Input Quantity Program,which is a frame with a text field,buttons for numbers,buttons for Cancel and Confirm. The quantity that is confirmed by the user will be accessed by the menu program from the Input Quantity Program to be stored in a vector so that every time a user wants to order other food items he will just click another button and repeat the process.

Now I've coded the most part and got everything working except one thing,the value returned by the Input Quantity Program has this delay thing. 

This is what I do step by step: 

1)Click a food item in Menu,it opens the Input Quantity window.  

2)I input the number I want,it displayed in the text box correctly.  

3)I pressed confirm which will do 3 things,first it stores the value of the text field to a variable,second it will call the dispose() method and third a print statement showing the value of the variable(for testing purposes).  

4)The menu program then checks if the user has already pressed the Confirm button in the Input program,if true it shall call a method in the Input program called getQuantity() which returns the value of the variable 'quantity' and store it in the vector.  

5)After which executes another print statement to check if the passed value is correct and then calls the method print() to show the ordered item name and it's recorded quantity. 

Here are the screenshots of the GUI and the code will be below it.

![MENU GUI](https://i.stack.imgur.com/sTzph.png)  

![1st order](https://i.stack.imgur.com/fkDQz.png)
![last order](https://i.stack.imgur.com/BYrWB.png)

ActionPerformed method of the CONFIRM BUTTON in the Input Quantity Program: 

```
private void ConfirmButtonActionPerformed(java.awt.event.ActionEvent evt) {                                              
    // TODO add your handling code here:
    confirmed = true;
    q= textField.getText().toString();
    quantity =Integer.parseInt(q) ;
    System.out.println("getQTY method inside Input Quantity Interface:" +getQuantity());
    System.out.println("Quantity from confirmButton in Input Quantity Interface actionPerformed: "+quantity);

    //getQuantity();
}                            

```

ACTION LISTENER CLASS of the MENU ITEM BUTTONS in MENU PROGRAM which does step 2 above: 

```
class f implements ActionListener {
    @Override
    public void actionPerformed(ActionEvent e) 
    {
         inputGUI.setVisible(true);
         int  q =0;

          q=inputGUI.getQuantity(); //call method to get value from Input Program

          System.out.println("Quantity inside Menu actionperformed from AskQuantity interface: "+q);

         orderedQuantity.add(q); //int vector
         textArea.append("\n"+e.getActionCommand()+"\t"+ q);
         orderedItems.add(e.getActionCommand());  //String vector
         print();
         /*
         System.out.println("Enter QTY: ");
         int qty = in.nextInt();
         orderedQuantity.add(qty);
         print();*/
   }

```

Here are screenshots of the print statements in the console:  

Here I first ordered Pumpkin Soup,I entered a quantity of 1  

![1st Order](https://i.stack.imgur.com/GMlLc.jpg) 

Here I ordered seafood marinara and entered a quantity of 2  

![2nd order](https://i.stack.imgur.com/OoSiZ.jpg)

Here I ordered the last item,pan fried salmon and entered a quantity of 3 

![enter image description here](https://i.stack.imgur.com/cX28B.jpg) 

As you can see the first recorded quantity is 0 for the first item I ordered then when I added another item,the quantity of the first item gets recorded but the 2nd item's quantity is not recorded..same goes after the third item... and the quantity of the 3rd item is not recorded even if the program terminates :( 

How can I solve this problem?