This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes cointainer/components size & diamentions! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "cointainer/components size & diamentions!" Watch "cointainer/components size & diamentions!" New topic
Author

cointainer/components size & diamentions!

Mandar Khire
Ranch Hand

Joined: Sep 11, 2007
Posts: 492

For any container/component we can use following 4 settings
setPreferredSize(), setMaximizedBounds(),setMaximumSize(),setMinimumSize().

My question is
Scenario:-
I am creating hierarchical structure.

Frame which contain 8main tabs which each tab contain 5 sub tabs. In each sub tab contain 4 sub-sub tab. Each sub-sub tab contain object of Jpanel which contain Form like structure...lots of textfields/buttons/radiobuttons etc
All some thing like this

JFrame-->Containtpane-->JTabbedpane-->Jpanel-->JTabbedpane-->Jpanel-->JTabbedPane-->Jpanel

For any system resolution frame should keep its size 1024*768.(This because for set smallest resolution).
All its contains should inside it..
So i try each thing its containers -5 like (containerwidth-5,containerhight-5)
So i got lots of integers,rectangles, dimensions...
I create excel sheet to maintain all this...Cross refer really i set properly or wrongly...

Smallest panel i got 984*733 (as per calculation)

Question :-
1. Is there any easy way to do this all things...
2. By setting all 4(setPreferredSize(), setMaximizedBounds(),setMaximumSize(),setMinimumSize()) same values then...is it right or wrongly i am doing?


Millions saw the apple fall, but Newton asked why.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Mandar Khire wrote:For any container/component we can use following 4 settings
setPreferredSize(), setMaximizedBounds(),setMaximumSize(),setMinimumSize().

Nope. One of those isn't a method of Component.

Mandar Khire wrote:My question is
...
...
Question :-
1. Is there any easy way to do this all things...
2. By setting all 4(setPreferredSize(), setMaximizedBounds(),setMaximumSize(),setMinimumSize()) same values then...is it right or wrongly i am doing?

Wrong. Learn to use Layout Managers. And in most cases, don't set any of the min/max/preferred size. Let the components and their containers compute their own sizes.


luck, db
There are no new questions, but there may be new answers.
Mandar Khire
Ranch Hand

Joined: Sep 11, 2007
Posts: 492

Thanks Darryl Burke,
Sorry for late reply..
Learn to use Layout Managers.

Let the components and their containers compute their own sizes.


I use border layout for all possible things... & keep each inherited thing as BorderLayout.CENTER.
So it look as what i need. I print all bounds also...
only Frame which i give specific values x,y,width,height all other x=0,y=0,width=0,height =0.
It works on any resolution..no problem...but question remain if i use absolute layout everywhere then?

i use jtattoo for look & feel...
It shows wrong values in print statement

example i create example.java which has
JFrame-->layerepane-->contentpane-->1st level JTabbedpane-->jpanel-->2nd level Jtabbedpane-->Jpanel-->3rd level Jtabbedpane-->Jpanel-->object of java file which extend Jpanel.

i keep Frames width & hight as 1019 X 733.
When normal program using following look & feel

i got vlaues as below.

when the Jtatto.jar's Look and Feel use...

few values i got wrong...if i see the running frame it not shown visibly anything wrong...
But in future may be this wrong values give trouble!
My main question is
1. Is there any other look & feels jar (by free download) so without same type of error i should not get but it look better than default 5 look & feel.
2. As per 'compute their own sizes' but in any supported platforms & their various versions it works properly?
Or for that i should do something different?
Mandar Khire
Ranch Hand

Joined: Sep 11, 2007
Posts: 492

As i write before i got wrong values by using look & feel jar which is open source...
I got little bit solution...
As i create example.java by eclipse indigo IDE's windowsbuilder which provide drag & drop facility to create component.

So basic example i create which code generated by automatically.
abcd.java which contain Frame-->layeredpane-->contentpane-->Jtabbedpane-->Jpanel.

When no look & feel use means default look & feel use then

Frame getbounds =java.awt.Rectangle[x=0,y=0,width=450,height=300]
Frame getLayeredPane() getbounds =java.awt.Rectangle[x=0,y=0,width=0,height=0]
Frame getContentPane() getbounds =java.awt.Rectangle[x=0,y=0,width=0,height=0]
tabbedPane getbounds =java.awt.Rectangle[x=0,y=0,width=0,height=0]
panel getbounds =java.awt.Rectangle[x=0,y=0,width=0,height=0]
panel_1 getbounds =java.awt.Rectangle[x=0,y=0,width=0,height=0]

When i use look & feel it give me

Frame getbounds =java.awt.Rectangle[x=0,y=0,width=450,height=300]
Frame getLayeredPane() getbounds =java.awt.Rectangle[x=0,y=0,width=0,height=0]
Frame getContentPane() getbounds =java.awt.Rectangle[x=0,y=0,width=0,height=0]
tabbedPane getbounds =java.awt.Rectangle[x=0,y=0,width=0,height=0]
panel getbounds =java.awt.Rectangle[x=1,y=67,width=-2,height=-68]
panel_1 getbounds =java.awt.Rectangle[x=1,y=67,width=-2,height=-68]

When i remove
window.frame.setVisible(true);
from psvm
& put
frame.setVisible(true);
in initialize() before print statements.
It give me output

Frame getbounds =java.awt.Rectangle[x=0,y=0,width=450,height=300]
Frame getLayeredPane() getbounds =java.awt.Rectangle[x=5,y=5,width=440,height=290]
Frame getContentPane() getbounds =java.awt.Rectangle[x=0,y=22,width=440,height=268]
tabbedPane getbounds =java.awt.Rectangle[x=0,y=0,width=440,height=268]
panel getbounds =java.awt.Rectangle[x=1,y=31,width=438,height=236]
panel_1 getbounds =java.awt.Rectangle[x=1,y=31,width=438,height=236]

Now question is when i not put x,y for layeredpane 5,5 or other's x,y how it comes...it assign due to java default assigned?
or somewhere i make mistake?
Waiting for reply...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: cointainer/components size & diamentions!
 
Similar Threads
Sizing an application to an image
JtabbedPane & bringing in other classes
Disposing of Objects
gui component sizes
Multiple equal tabs in jTabbedPane