Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-26-2009, 05:05 PM
Member
 
Join Date: Nov 2009
Posts: 2
Rep Power: 0
Nyet is on a distinguished road
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!
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 11-26-2009, 05:10 PM
PhHein's Avatar
Senior Member
 
Join Date: Apr 2009
Location: Germany
Posts: 491
Rep Power: 1
PhHein is on a distinguished road
Default
Hi,
read this tutorial, it's helpful. Lesson: Laying Out Components Within a Container (The Java™ Tutorials > Creating a GUI With JFC/Swing)
__________________
Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 11-26-2009, 05:59 PM
Member
 
Join Date: Nov 2009
Posts: 2
Rep Power: 0
Nyet is on a distinguished road
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?
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 11-26-2009, 06:35 PM
PhHein's Avatar
Senior Member
 
Join Date: Apr 2009
Location: Germany
Posts: 491
Rep Power: 1
PhHein is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 11-27-2009, 04:13 AM
Senior Member
 
Join Date: Aug 2009
Location: Pittsburgh, PA
Posts: 265
Rep Power: 1
zweibieren is on a distinguished road
Default
Take a good look at Box and BoxLayout
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Window Resizing issue er91ic512 AWT / Swing 2 07-28-2009 01:48 PM
Resizing Images in JPanel?? NoNickName New To Java 1 04-09-2009 11:19 PM
Window resize icon... pele SWT / JFace 3 06-09-2008 09:31 AM
How to resize the components with the change in the size of the window? shaunak kiwalkar SWT / JFace 1 06-06-2008 08:55 AM
Problems with gridBaglayout when I resize the window Iyengar AWT / Swing 1 02-17-2008 12:43 AM


All times are GMT +2. The time now is 07:10 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org