Results 1 to 8 of 8
  1. #1
    thunderbird is offline Member
    Join Date
    Apr 2010
    Posts
    1
    Rep Power
    0

    Default Multiple Menu Program

    Hi,

    I want to create a program in Java, and I am using JFrames for my GUI. What the program does is that it has some buttons on a JFrame and each button does an event. One of this buttons has to lead in a new menu.
    I have decided that the best way to do this is to create two JFrames, set the one to visible (i.e. setVisible(true)) and the other one invisible (i.e setVisible(false))
    When I press on the button I want the first frame to become invisible and the second one visible so I will be able to view the new menu.

    Is there any way to do this? If you want my code so far I can post it here, just let me know guys.

    Thanks

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

  3. #3
    chyrl is offline Senior Member
    Join Date
    Mar 2010
    Location
    Manila, Philippines
    Posts
    257
    Rep Power
    5

    Default

    How about using the add(Component c) and remove(Component c) then use the repaint and revalidate. I think it would be better.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is online now Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,242
    Rep Power
    19

    Default

    Quote Originally Posted by chyrl View Post
    How about using the add(Component c) and remove(Component c) then use the repaint and revalidate. I think it would be better.
    Oh yeah? Kindly explain how remove/add/revalidate/repaint (NOT as you propose, add/remove/repaint/revalidate) would be better that using a LayoutManager that is a perfect fit and makes swapping of components a one-liner.

    db

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

    Default

    Quote Originally Posted by chyrl View Post
    How about using the add(Component c) and remove(Component c) then use the repaint and revalidate. I think it would be better.
    Ditto on what Darryl stated: Can you elaborate on how this is better than CardLayout?

  6. #6
    chyrl is offline Senior Member
    Join Date
    Mar 2010
    Location
    Manila, Philippines
    Posts
    257
    Rep Power
    5

    Default

    Actually the remove/add/revalidate/repaint is just for the menu to display or not.

    thunderbird could actually create an constructor to the second frame containing the data of the first frame as its parameter. setVisible(boolean flag) isn't a best solution, in terms of memory consumption.

    BTW, can anyone help me on my thread regarding 'how to reload JIF'. Thanks.
    Last edited by chyrl; 04-05-2010 at 05:00 AM.

  7. #7
    Michael Dunn is offline Member
    Join Date
    Jul 2008
    Posts
    62
    Rep Power
    0

    Default

    > BTW, can anyone help me on my thread regarding 'how to reload JIF'.

    despite a several requests for a more detailed explanation of the problem,
    you continue with your 'feet on the desk' attitude, waiting for someone else to do the work.

    I'd love to be your boss, well, I wouldn't be 'your boss' for long.

  8. #8
    chyrl is offline Senior Member
    Join Date
    Mar 2010
    Location
    Manila, Philippines
    Posts
    257
    Rep Power
    5

    Default

    Quote Originally Posted by Michael Dunn View Post
    > BTW, can anyone help me on my thread regarding 'how to reload JIF'.

    despite a several requests for a more detailed explanation of the problem,
    you continue with your 'feet on the desk' attitude, waiting for someone else to do the work.

    I'd love to be your boss, well, I wouldn't be 'your boss' for long.
    Thanks for that

Similar Threads

  1. Connecting to Multiple Clients in a Chat Program
    By Gregadeaux in forum Networking
    Replies: 0
    Last Post: 12-09-2009, 01:41 AM
  2. multiple program
    By mm2236 in forum Threads and Synchronization
    Replies: 2
    Last Post: 10-02-2009, 12:27 PM
  3. Working on a menu program...using exceptions
    By Nightwarrior in forum New To Java
    Replies: 0
    Last Post: 04-16-2009, 04:40 AM
  4. need menu program
    By student_doesntget_java in forum New To Java
    Replies: 2
    Last Post: 03-20-2009, 09:58 AM
  5. Replies: 4
    Last Post: 10-02-2008, 10:05 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
  •