I have 2 frame in my one application. sum of two given number.
1st Frame: contains one JButton(will open 2nd frame) and one JLabel(print the return value from 2nd frame).
2nd Frame: contains two JTextField(For input two values) and one JButton(will sum the given values and return it to first frame or print it to JLabel of 1st frame).
Now My problem is I can not return the sum value from 2nd frame to 1st frame. What should I do? How can I get the sum value from 2nd frame.
Can anybody give me the sample code or any simple solution or may be any useful link????
Answer: don’t use two JFrames. Instead, that second “frame” should be a modal dialog such as a JDialog or a JOptionPane. The reason this is important is that you’ll make the second window appear from the first one, and the first window will know exactly when the user has finished dealing with the second window since program flow will resume right from the spot where it was initially set visible. It is then that the first window/class can query the second for the state of its variables and use them however it sees fit.