Results 1 to 12 of 12

Thread: Java Panels

  1. #1
    nikkka is offline Member
    Join Date
    Mar 2011
    Posts
    45
    Rep Power
    0

    Default Java Panels

    How can I divide a panel into a different sub-panels?

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

  3. #3
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    While more clarification is needed i will attempt to read your mind. You can add multiple sub panels to one panel. For instance, you can put a panel on the top with buttons, a panel at the bottom with check boxes and an image in the center of the original panel.

  4. #4
    nikkka is offline Member
    Join Date
    Mar 2011
    Posts
    45
    Rep Power
    0

    Default

    That's what I mean...
    Attached Thumbnails Attached Thumbnails Java Panels-panels_in_panels.jpg  

  5. #5
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    Alright, this is possible however; I will leave the research up to you. The sun tutorials should have some examples of something like this.

  6. #6
    nikkka is offline Member
    Join Date
    Mar 2011
    Posts
    45
    Rep Power
    0

    Default

    Quote Originally Posted by sunde887 View Post
    You can add multiple sub panels to one panel.
    How?
    Thank you, anyway :)

  7. #7
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    Try creating some panels , put a button on two of them then add them to the third. Then add the panel to a frame and make it visible

  8. #8
    nikkka is offline Member
    Join Date
    Mar 2011
    Posts
    45
    Rep Power
    0

    Default

    this way?

    Java Code:
    JFrame f = new JFrame();
    f.setTitle("Window");
    f.setSize(200,300);
    JPanel p = new JPanel();
    p.setLayout(new GridLayout(2,1,5,5));
    JPanel c = new JPanel();
    p.setLayout(new GridLayout(1,2,5,5));
    c.add(Button1);
    c.add(Button2);
    p.add(c);
    p.add(Button3);
    it doesn't work...

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

    Default

    You should simply nest JPanels, each one using the best layout manager for its situation. If you need help, then you may wish to create a Short, Self Contained, Correct (Compilable), Example or SSCCE. This is a small program that compiles, runs, demonstrates your problem, and contains no extraneous code. Please read the link, and have a go at it.

  10. #10
    nikkka is offline Member
    Join Date
    Mar 2011
    Posts
    45
    Rep Power
    0

    Default

    Is my code correct? It doesn't work...

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

    Default

    Quote Originally Posted by nikkka View Post
    Is my code correct? It doesn't work...
    Who knows. Again, click on the SSCCE link to learn to create and post code that we can actually run and test, and then be able to answer your question.

  12. #12
    nikkka is offline Member
    Join Date
    Mar 2011
    Posts
    45
    Rep Power
    0

Similar Threads

  1. Java Panels and Layouts help
    By Zookey in forum New To Java
    Replies: 2
    Last Post: 01-30-2011, 12:06 PM
  2. Deleting panels
    By dilpreet28 in forum New To Java
    Replies: 13
    Last Post: 08-11-2010, 09:23 AM
  3. issue of mutiple panels
    By de.megha in forum AWT / Swing
    Replies: 1
    Last Post: 07-26-2010, 09:27 AM
  4. resizeable panels
    By simo_mon in forum AWT / Swing
    Replies: 4
    Last Post: 07-29-2009, 01:45 AM
  5. I obviously don't understand positioning panels
    By javatard in forum New To Java
    Replies: 2
    Last Post: 12-10-2008, 07:48 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
  •