Results 1 to 8 of 8
  1. #1
    jasonwucinski is offline Member
    Join Date
    Feb 2011
    Posts
    64
    Rep Power
    0

    Default What's the best method

    Hello all. I'm creating a desktop application and was wondering what the best method for the following scenario is:

    On my main application I have a mainPanel (created by default). I want to create several panels, each with their own set of controls, and when the user selects an item from the Menu, add the corresponding panel to the main panel. Should i do this Tabbed pane? or is there a way to create each on a Panel and swap panels?

    thanks
    jason

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

  3. #3
    RichersooN is offline Senior Member
    Join Date
    Jan 2011
    Location
    Rizal Province, Philippiines
    Posts
    167
    Rep Power
    0

    Default

    You can set your layout to null

  4. #4
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,365
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by RichersooN View Post
    You can set your layout to null
    Which would be a very stupid thing to do: a CardLayout or just a JTabbedPane would do the job much better (and makes your application independent from the actual screen resolution; working without layout managers is for script kiddies that don't know better).

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    I don't think setting the layout to null really addresses the problem. In effect it is a reccomendation to not use the Swing layout mechanism at all which would leave the OP at square one still trying to figure out how to display what he wants.

    Picking up on the last question the OP poses - "is there a way to create each on a Panel and swap panels?" - that is precisely what a CardLayout (or tabbed pane) is designed to do. Even if the OP decided to use a null layout (in general a Bad Thing) then there would still be the question of what sort of container to add. I agree with what Fubarable suggests: what should be added is a panel with a card layout.

  6. #6
    jasonwucinski is offline Member
    Join Date
    Feb 2011
    Posts
    64
    Rep Power
    0

    Default

    Thanks everyone! I'll look into the cardlayout.

  7. #7
    oomrichie is offline Member
    Join Date
    Feb 2011
    Posts
    31
    Rep Power
    0

    Default

    If you decide on using a Tabbed pane i have a nice UI for it
    I attach it as a .txt just make it a java file, you can use it like ass follows:

    Java Code:
    JTabbedPane_1.setUI(new AquaBarTabbedPaneUI());
    Attached Files Attached Files
    Last edited by oomrichie; 04-30-2011 at 11:11 PM.

  8. #8
    oomrichie is offline Member
    Join Date
    Feb 2011
    Posts
    31
    Rep Power
    0

Similar Threads

  1. Declaring a method inside a method: Runnable?
    By africanhacker in forum New To Java
    Replies: 8
    Last Post: 03-23-2011, 04:30 AM
  2. Thread problem, calling method in run method
    By majk in forum Threads and Synchronization
    Replies: 4
    Last Post: 09-27-2010, 11:40 AM
  3. Replies: 2
    Last Post: 03-26-2010, 05:12 PM
  4. ArrayLists compareTo method, equals method
    By random0munky in forum New To Java
    Replies: 2
    Last Post: 10-26-2009, 07:20 PM
  5. cannot call private method from static method
    By jon80 in forum New To Java
    Replies: 3
    Last Post: 05-07-2008, 08:37 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
  •