Results 1 to 5 of 5
  1. #1
    vmcg is offline Member
    Join Date
    Jul 2010
    Posts
    4
    Rep Power
    0

    Default Switching Screens

    New to Java, this may seem like a stupid question to some but what is the best way to switch screens in Java. For example say I load my program up at the intro screen, and I select a new option from my JMenuBar. What is the best to load the screen and close the current one. I would imagine there must be a better way than changing the setVisible.

    Basically does anyone have a good design pattern for a menu system program, jumping between screens and keeping global variables, such as the userid from example.

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,899
    Rep Power
    25

    Default

    What is a screen? A window, dialog, JOptionPane, frame or ?

  3. #3
    vmcg is offline Member
    Join Date
    Jul 2010
    Posts
    4
    Rep Power
    0

    Default

    Say a jframe for example, and i want to load up a new one and close the existing one.

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,899
    Rep Power
    25

    Default

    What methods are in the API doc for JFrame or the classes that it extends that look like they would "close" it?
    Look at dispose and setVisible for example.
    Do you have a copy of the API doc?

  5. #5
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,236
    Rep Power
    7

Similar Threads

  1. Calculator Switching
    By dilpreet28 in forum New To Java
    Replies: 9
    Last Post: 06-08-2010, 03:05 AM
  2. Switching Frames
    By jonnytabpni in forum New To Java
    Replies: 1
    Last Post: 11-08-2009, 11:12 PM
  3. problem with JFrames in different screens
    By petrosgraf in forum Java 2D
    Replies: 1
    Last Post: 04-17-2009, 08:04 PM
  4. switching packages
    By DuceDuceExplorer in forum NetBeans
    Replies: 4
    Last Post: 07-10-2008, 12:11 AM
  5. New to Java, Creating screens with swings on Mac OS X
    By mo_mughrabi in forum New To Java
    Replies: 0
    Last Post: 05-26-2008, 02:17 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
  •