Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / November 2003

Tip: Looking for answers? Try searching our database.

Setting size for multiple JPanel objects on single frame (newbie)

Thread view: 
fareeda - 03 Nov 2003 08:36 GMT
Hi,

I have added 2 JPanel objects in my JFrame. The number of objects in
both are not same and hence I would expect both to occupy different %
of the overall JFrame space.
But when the form is loaded, all JPanel objects have same size and
hence the Panel with less number of objects has a gray area at the
bottom.

My guess is I need to do something with the layout manager but could
not get what. I am using grid layout in both panels. Since one of them
needs to be a 2 column panel while not the other one, I had to use
this layout.

any pointer would help.. thanks
Fareeda
Babu Kalakrishnan - 04 Nov 2003 13:17 GMT
> Hi,
>
[quoted text clipped - 9 lines]
> needs to be a 2 column panel while not the other one, I had to use
> this layout.

The reason why you need a GridLayout for your panels is not very clear -
but the relative size of the two panels would depend on the layout
manager employed in the container into which you're inserting these
panels. (presumably the contentPane of the JFrame ?). If you have set a
GridLayout for it, you should naturally expect the size of both panels
to be equal because that is the designed behaviour of a GridLayout (It
divides the entire area into grids that are of equal sizes).

If you need the area allocation to be in proportion to what each panel
holds, you need to use a different LayoutManager. It is a good thing to
read up on the functionalities provided by at least the simpler
LayoutManagers that are available in the Java library - (e.g.
FlowLayout, BorderLayout, BoxLayout, GridLayout etc) before you embark
on any GUI design task. Try Sun's Java Tutorial for a start.

BK


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.