That's what...
I have 2 GUI programs.
The menu program, which basically consists of a frame with food buttons, pressing this button opens this other program, the quantity input program, which is a frame with a text field, buttons for numbers, buttons for canceling and confirmation. The quantity confirmed by the user will be accessible by the menu program from the quantity input program, which will be stored in the vector, so every time the user wants to order other food products, he simply presses another button and repeats the process.
Now I have encoded most of it and got everything except one, the value returned by the quantity input program has this delay.
This is what I am doing step by step:
1) Press the power item in the menu, the Number of input data window opens.
2) I enter the number I want, it displays in the text box correctly.
3) I pressed the confirmation button, which will do 3 things, first save the text field value for the variable, then call the dispose () method and the third print statement showing the variable value (for testing purposes).
4) Then the menu program checks whether the user pressed the confirmation button in the input program, if it is true, it should call a method in the input program called getQuantity (), which returns the value of the quantity variable and stores it in the vector.
5) After that, another print statement is executed to check the correctness of the passed value, and then calls the print () method to display the name of the ordered element and its quantity.
Here are the screenshots of the GUI, and the code will be below.



The ActionPerformed CONFIRM BUTTON method in the quantity input program:
private void ConfirmButtonActionPerformed(java.awt.event.ActionEvent evt) {
CLASS OF ACTION CLASS BUTTONS OF THE MENU BUTTON in the 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();
Here are screenshots of the print statements on the console:
Here I first ordered pumpkin soup, I entered the quantity 1

Here I ordered marinara seafood and entered quantity 2

Here I ordered the last item, fried fried salmon and entered the amount of 3

As you can see, the first recorded value is 0 for the first element that I ordered, when I added another element, the number of the first element is recorded, but the number of the second element is not recorded .. the same thing happens after the third element ... and the amount of the third element is not written even if the program terminates :(
How can I solve this problem?