Solved

swing layouts & resizing

Posted on 2006-11-17
12
1,660 Views
Last Modified: 2010-08-31
I have a JDialog.  The layout used by this JDialog is SpringLayout.  I have two JPanels within this JDialog.  I would like both of these panels to resize when I resize the JDialog.  How can I do this?
0
Comment
Question by:abcast
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
12 Comments
 
LVL 10

Accepted Solution

by:
ADSLMark earned 125 total points
ID: 17968494
I am not sure how your panels are placed, but I can imagine you have two panels one left, one right, but why use SpringLayout for this? Maybe you could make a picture on how you want the controls to be situated and then we can see what you want.

I don't see any reason why the panels would not resize if you put the constraints correctly.

Mark
0
 

Author Comment

by:abcast
ID: 17968624
Actually, I've adjusted my layout selection a bit.  I now have a GridBagLayout with a bunch of components, and then at the bottom I have a JPanel w/ some buttons.  When I resize horizontally, everything seems to respond as I want it to.  However, when I resize vertically, nothing that I want to resize actually resizes.  I have the fill set to BOTH on the constraints, though...
0
 
LVL 92

Assisted Solution

by:objects
objects earned 125 total points
ID: 17968717
how exactly do u want them to resize?  If you want them to be the same size then use a GridLayout.
If you want one to take all the available space then use a BorderLayout
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Comment

by:abcast
ID: 17968773
How can I do this with a GridBagLayout though? I know there must be some way.  I want the JLabels to stay the same size, but the JTextFields to increase their vertical size as the user resizes the form.
0
 
LVL 92

Expert Comment

by:objects
ID: 17968840
use a BorderLayout for that
0
 

Author Comment

by:abcast
ID: 17968870
Well, I would like to use a GridBagLayout because I want to control the vertical and horizontal spacing between some of the components.
0
 
LVL 92

Expert Comment

by:objects
ID: 17968904
can't help you sorry, i never use it. find it far too cryptic and never found a layout that couldn't be done with other managers.
0
 
LVL 15

Assisted Solution

by:Javatm
Javatm earned 125 total points
ID: 17969259
> How can I do this with a GridBagLayout though?
http://java.sun.com/docs/books/tutorial/uiswing/layout/gridbag.html
0
 
LVL 6

Assisted Solution

by:SamsonChung
SamsonChung earned 125 total points
ID: 17969295
A possible version would be to define some rations that you want.

so, for example,

I want my jtextArea to be w:2, h:4

then, take the total width of your jframe, divide that into a number that make sense, such as default is set at 50.

where then you have a JtextAra that is width at 100 height at 200 if you multiply it.

then set the jtextarea's width and height to that generated number.

now, on redraw, update all of this based on the Jframe's width and height.

this the the advanced crazy way.. .where layout is nearly customized.

Also, if you get stuck, i remember there are programs that helps you by generating Java Swing code based on a click and drag input screen.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Way to decrease size of apk file 9 110
Java Restore security prompts not working 10 140
Crystal Reports Licensing Questions 4 65
JDBC performance 8 29
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question