Results 1 to 2 of 2
  1. #1
    jonnytabpni is offline Member
    Join Date
    Nov 2009
    Posts
    8
    Rep Power
    0

    Default Switching Frames

    Hi Folks,

    I'm new to Java but I come from a C# background (Also a beginner there as well).

    I've made a simple MDI app in java. My app starts off displaying a single child frame (The Main Menu) which has lots of buttons. I wish to open new child frames by pressing these buttons.

    Initally, I had this in the action performed for the respect button:

    new Frame2().show();
    this.dispose;

    While the above 2 lines worked, the dispose method of the first form would take focus of the screen (Meaning the user would have to do an inital click on the new form to gain focus).

    Now, I swapped the 2 lines of code around:

    this.dispose;
    new Frame2().show();

    and everything seems to work OK, however is this "the correct way" to go about things? Will the Garbage collector free the memory that the first form was taking up? (Hopefully it will!)

    Thanks for the help

    Jonny

  2. #2
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,226
    Rep Power
    6

    Default

    Will the Garbage collector free the memory that the first form was taking up? (Hopefully it will!)
    The order won't affect garbage collection.

    is this "the correct way" to go about things?
    Sure, except you should be using frame.setVisible( true );

Similar Threads

  1. (Solved)switching from frame to another
    By HosHos in forum AWT / Swing
    Replies: 2
    Last Post: 08-11-2009, 02:19 PM
  2. Multi Protocol Label Switching ?!
    By gopithamizh in forum New To Java
    Replies: 1
    Last Post: 02-11-2009, 07:08 AM
  3. Switching Careers to Java? It's never to late, is it?
    By /-ICEpik in forum Jobs Discussion
    Replies: 10
    Last Post: 12-30-2008, 05:03 PM
  4. switching packages
    By DuceDuceExplorer in forum NetBeans
    Replies: 4
    Last Post: 07-09-2008, 11:11 PM
  5. switching between HTTP and HTTPS
    By mutuah in forum Advanced Java
    Replies: 6
    Last Post: 08-03-2007, 10:08 PM

Posting Permissions

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