Results 1 to 4 of 4
  1. #1
    cranberries__ is offline Member
    Join Date
    Jan 2010
    Posts
    2
    Rep Power
    0

    Default Help???transition btween frames ??

    hi friends,
    ı've designed 2 frames.and ı want to close the first frame when I clicked one of the buttons on the fisrt frame.Also, I wanna open the second frame when I clicked this button.How can I do this?
    help????

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Hello and welcome to the forum!

    There are several options you can do here, including simply setting the current JFrame's visible property to false and the other JFrame's property to true via the JFrame#setVisible(boolean visible) method.

    But there are other and perhaps more important issues involved here, issues that if you address could help us give you more than just general answers. From a tactical point of view, there are scope issues -- are both JFrame variables visible from within the button's action listener and if not, how to make them visible. Your program structure and code would tell us more about how to deal with this.

    And perhaps more importantly still are the strategic issues -- just what you are trying to do in an overall general sense, not in a Java or Swing sense? The reason this is so important is that often swapping JFrames is precisely not what you really what you want to do here. If you think of the programs you know and use, word processors and such, it is uncommon where you'll see swapping GUI windows. More often you'll see a main GUI window with occational dialogs, sometimes you'll have different GUI panels held in tabbed panes, and sometimes you'll see GUI panels or views swapped within a main application (within a single stable JFrame).

    So in that mode, what is your goal here? Are you trying to do a log-on dialog that when completed opens the main GUI? Are you instead trying to get input from the user to allow them to change a property of your program? Our recommendations will likely depend on this.

    Much luck and hope we can help! Oh, and again, welcome!
    Last edited by Fubarable; 01-10-2010 at 06:35 PM.

  3. #3
    cranberries__ is offline Member
    Join Date
    Jan 2010
    Posts
    2
    Rep Power
    0

    Default

    Thank you:=)
    Actually ,I will desgin a hospital automation system.The first frame which I've desgined is "Introduction Menu".This Frame includes a button which open "Doctor Menu" ..
    The code I've writtn ,for the first frame is:
    JFrame frame0=new JFrame();
    frame0.setVisible(false);
    this.setVisible(false);

    And I've written for the second frame ( under the main function)

    JFrame frame2=new JFrame();
    frame2.setVisible(true);
    When I compiiled, first frame closed but second frame was nor opening as I ve designed.An empty frame was coming.
    ??

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    1) Consider using a CardLayout to swap JPanels rather than JFrames.
    2) If you really need to use swapping JFrames, then you'll have to give us more information for us to be able to figure out what's wrong. For one, we'll need to see more code, but please don't forget to use code tags when you post your code (please see my signature below).

    Much luck.

Similar Threads

  1. navigation b/w frames
    By imrankhan in forum AWT / Swing
    Replies: 3
    Last Post: 03-19-2012, 01:25 PM
  2. SWT Transition Widget - STW
    By fossilman2005 in forum SWT / JFace
    Replies: 0
    Last Post: 01-03-2010, 12:16 AM
  3. Switching Frames
    By jonnytabpni in forum New To Java
    Replies: 1
    Last Post: 11-08-2009, 11:12 PM
  4. C++ to Java transition
    By Mareq in forum New To Java
    Replies: 2
    Last Post: 08-10-2009, 07:31 AM
  5. Help regarding Frames
    By ramesh.8189 in forum AWT / Swing
    Replies: 14
    Last Post: 02-15-2009, 09:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •