-1

let's say that i have 2 JFrames (A) & (B)

Frame (A) fires Frame (B), as follows

line 1: private void fun1()
line 2: {
line 3:      new B();
line 4:      Do something
line 5: }

in line 3 i activate frame B.. i don't wanna go-to line 4 until i turn back from JFrame (B) becuase according to some actions in Frame (B) i do some action like this

new (B);
container.add(JPanel);

container.add(JPanel); --> depends on a flag fired from JFrame (B)

Radu Murzea
  • 10,724
  • 10
  • 47
  • 69
BDeveloper
  • 1,175
  • 6
  • 24
  • 44
  • 4
    http://stackoverflow.com/a/9554657/758280 – Jeffrey Jun 12 '12 at 22:18
  • @Jeffrey Unfortunately, this has all been [said before](http://stackoverflow.com/questions/10885784/adding-frames-to-mainframe) to the OP with no apparent effect. Maybe if they hear it coming from **3** other people, it will sink in. – Andrew Thompson Jun 12 '12 at 22:43
  • Ok let's say that i've changed JFrame (B) to JDialog ... this dialog is a custom Dialog... i've 3 butttons Add, Reset, and cancel... i want tp show my Dialog from Frame (A) and do nothing until the user in Dialog (B) "which should be always in the top" clicks Add... then according to that action i'm gonna add a certain panel in Frame (A) – BDeveloper Jun 13 '12 at 01:54
  • my question is: How could i wait for the user to click on add in dialog (B) to turn back to mainFrame (A) and to add the panel it explained before.. – BDeveloper Jun 13 '12 at 02:07
  • what would be the call from Frame (A) – BDeveloper Jun 13 '12 at 02:08
  • 1
    This is how modal dialogs work. The main GUI's code essentially stops from the moment you set the modal dialog as visible. Then the main GUI's code will not resume until the modal dialog is no longer visible. Swing does all of this automatically for you -- Try it and see. – Hovercraft Full Of Eels Jun 13 '12 at 02:09

1 Answers1

6

Consider using a modal dialog to display the contents of frame B.

lhballoti
  • 806
  • 7
  • 17
  • 2
    Don't even consider -- just do it, because this is the correct answer. Don't use a second JFrame, but use a modal JDialog for the second window. 1+ up-vote. – Hovercraft Full Of Eels Jun 12 '12 at 22:18
  • 2
    @HovercraftFullOfEels Unfortunately, this has all been [said before](http://stackoverflow.com/questions/10885784/adding-frames-to-mainframe) to the OP with no apparent effect. Maybe if they hear it coming from **3** other people, it will sink in. – Andrew Thompson Jun 12 '12 at 22:44