Results 1 to 5 of 5
  1. #1
    Nyet is offline Member
    Join Date
    Nov 2009
    Posts
    2
    Rep Power
    0

    Default Problem resizing JPanel on window resize

    I am currently working on a GUI which has a JFrame which contains a JPanel which in turn contains several JPanels. I am using GridBagLayout for all of them, yet whenever I change the window's size (maximising or manually dragging) the JPanels stay the same size. I tried using fill but it only fills to the JFrame's original size, not when I resize it.
    I have tried a few things, I think it might be because I have JPanels inside JPanels, however I'd would like to be sure before changing my code that much.
    Thanks a lot for your help!

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default

    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  3. #3
    Nyet is offline Member
    Join Date
    Nov 2009
    Posts
    2
    Rep Power
    0

    Default

    Hi, thanks I had skimmed through that but missed the weight constraint :(
    Now I can at least stretch the JPanel to the size of the jframe when I increase the window's size, however the JPanels inside the JPanel do not change (I add weight and fill everywhere). Is it doable or do I have to add every component to the jframe manually and remove the JPanel?

  4. #4
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default

    No you don't need to do that. Let the LayoutManagers do the work. You can use nested LayoutManagers, like Borderlayout for the content pane and GridbagLayout for panel1 and FlowLayout for panel2 etc.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  5. #5
    zweibieren is offline Senior Member
    Join Date
    Aug 2009
    Location
    Pittsburgh, PA
    Posts
    284
    Rep Power
    5

Similar Threads

  1. Window Resizing issue
    By er91ic512 in forum AWT / Swing
    Replies: 2
    Last Post: 07-28-2009, 12:48 PM
  2. Resizing Images in JPanel??
    By NoNickName in forum New To Java
    Replies: 1
    Last Post: 04-09-2009, 10:19 PM
  3. Window resize icon...
    By pele in forum SWT / JFace
    Replies: 3
    Last Post: 06-09-2008, 08:31 AM
  4. Replies: 1
    Last Post: 06-06-2008, 07:55 AM
  5. Replies: 1
    Last Post: 02-16-2008, 11:43 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
  •