JFrames

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • senorita
    New Member
    • Oct 2007
    • 3

    JFrames

    I am trying to activate one Jframe from another JFrame. I dont want to keep the first frame visible when the second one is visible, but by the click of button on second frame the second frame should close and first one be visible.
    Both the frames are placed in seperate programs with main function in the program for first JFrame.
    Can anyone help me with the code.
    Thanx
  • Ramola
    New Member
    • Sep 2007
    • 35

    #2
    Originally posted by senorita
    I am trying to activate one Jframe from another JFrame. I dont want to keep the first frame visible when the second one is visible, but by the click of button on second frame the second frame should close and first one be visible.
    Both the frames are placed in seperate programs with main function in the program for first JFrame.
    Can anyone help me with the code.
    Thanx

    The point where u make an obj of the 2nd JFrame , call dispose() method immediately after it .


    Kind regards,
    Malavika

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Originally posted by senorita
      I am trying to activate one Jframe from another JFrame. I dont want to keep the first frame visible when the second one is visible, but by the click of button on second frame the second frame should close and first one be visible.
      Both the frames are placed in seperate programs with main function in the program for first JFrame.
      Can anyone help me with the code.
      Thanx
      1.) You should have only one main method
      2.) Disposing a JFrame (dispose) and making it invisible (setVisible(fal se)) are two different things.

      Comment

      • senorita
        New Member
        • Oct 2007
        • 3

        #4
        Originally posted by r035198x
        1.) You should have only one main method
        2.) Disposing a JFrame (dispose) and making it invisible (setVisible(fal se)) are two different things.
        Thanx but the problem remains same. I have only one main method in the program which activates first JFrame. when a button on first JFrame is clicked second JFrame is made visible but how do i go BACK FROM SECOND JFrame to FIRST JFrame, if first is hidden or disposed.

        Comment

        • Ganon11
          Recognized Expert Specialist
          • Oct 2006
          • 3651

          #5
          In the second JFrame, add a link back to the first JFrame. That is, add a member JFrame variable, and in the constructor, request a variable of type JFrame.

          Back in your first JFrame, when you make the second JFrame, pass it the this variable. When you're done in your second JFrame, set the first Frame visible again.

          Comment

          • senorita
            New Member
            • Oct 2007
            • 3

            #6
            Originally posted by Ganon11
            In the second JFrame, add a link back to the first JFrame. That is, add a member JFrame variable, and in the constructor, request a variable of type JFrame.

            Back in your first JFrame, when you make the second JFrame, pass it the this variable. When you're done in your second JFrame, set the first Frame visible again.
            Thank you it worked.

            Comment

            Working...