Hi, I have two windows: JFrame (main) and JDialog (seconday, pops up if I press button to change price). Now rest of code works well but I'm stuck at transfering new price from JDialog to JFrame. In JFrame's ActionListener I copied main method of JDialog, so it opens JDialog when pressed. But after it opens, rest of code from JFrame doesn't wait for ActionListener in JDialog, and continues rest of code.
To transfer data I'm using a helping class, so when I call JDialog I pass a object of that helper class and in JDialog I change value of one of attributes of that object. Knowing they share same address, object back in JFrame should also be changed.
How do I make it wait for ActionListener in JDialog?
HelperClass pom = new HelperClass();
System.out.println("COMMENT: before: " + pom.newPrice());
try {
pom.oldPrice = selectedProduct.getPrice();
ChangePrice dialog = new ChangePrice(pom);
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
dialog.setVisible(true);
dialog.setModal(true);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("COMMENT: after: " + pom.newPrice());
Here's a picture of GUI, but if it's not allowed to post pictures, let me know and I'll delete it.
Pictures:
<img src="https://postimg.cc/qtjTwwc7">
What I have tried:
I've tried creating a boolean that checks if the price has been changed and if yes, advances after the main method of JDialog but then it gets stuck and it never gets to do rest of code.