Results 1 to 4 of 4

Thread: Question

  1. #1
    vittoire is offline Member
    Join Date
    Jan 2010
    Posts
    9
    Rep Power
    0

    Default Question

    is it better for me to use 5 java files to form 1 whole gui program or is it better to place them inside a cardlayout?

  2. #2
    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 vittoire View Post
    is it better for me to use 5 java files to form 1 whole gui program or is it better to place them inside a cardlayout?
    That's like asking "is it better to wash my hands with soap or to have toast and eggs for breakfast?". The two statements above are not mutually exclusive. So my answer is:
    1) If your app is more than the most simple apps, then yes, break it down into multiple classes, and
    2) Use CardLayout if your GUI design calls for it.

    And again, the two answers above are completely unrelated to each other.

  3. #3
    vittoire is offline Member
    Join Date
    Jan 2010
    Posts
    9
    Rep Power
    0

    Default

    Thanks a lot for your reply. When i break it into muliple classes, what is the correct method to open the next class that i set in my actionlistener?

    class ButtonHandler implements ActionListener
    {
    public void actionPerformed(ActionEvent evt)
    {
    if(evt.getSource() == cpuButton)
    {
    CpuGenerate frame = new CpuGenerate();

    }
    if(evt.getSource() == mmButton)
    {
    MainMemory1 frame = new MainMemory1();
    }
    }
    }
    i used this actionlistener to open the class after the button have been clicked. but it opens the next class without the current one closing. Everytime i click on the button, it just open another class. how can i initialise it to close the previous frame & at the same time open the next frame?

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

    Default

    Myself, I'm not a big fan of opening and closing windows like this but rather using CardLayout to swap GUI views, but without more information, I find it hard to give you more precise advice without more information. Perhaps (hopefully) someone else will do better than me.

    Much luck.

Similar Threads

  1. Question mark colon operator question
    By orchid in forum Advanced Java
    Replies: 9
    Last Post: 12-19-2010, 09:49 AM
  2. RMI question
    By alvandrood in forum New To Java
    Replies: 1
    Last Post: 09-14-2009, 01:36 PM
  3. help me in dis question
    By krishan in forum New To Java
    Replies: 10
    Last Post: 02-16-2009, 08:04 PM
  4. ur help on my question
    By jameela in forum New To Java
    Replies: 4
    Last Post: 10-13-2008, 01:38 PM
  5. a question
    By slytheman in forum Java Servlet
    Replies: 0
    Last Post: 03-12-2008, 05:11 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
  •