• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

cointainer/components size & diamentions!

 
Ranch Hand
Posts: 630
Android Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Mandar Khire
Ranch Hand
Posts: 630
Android Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 630
Android Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
reply
    Bookmark Topic Watch Topic
  • New Topic