aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes GridBagLayout Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "GridBagLayout" Watch "GridBagLayout" New topic
Author

GridBagLayout

Marcela Blei
Ranch Hand

Joined: Jun 28, 2000
Posts: 477
Does anybody has a tutorial or some kind of documentation about GridBagLayout more clear than the API documentation because I was reading it and I tried the code but when I began changing that code the behavior of the layout wasn�t the behavior I expected.
I read that some settings of GridBagConstraints invalidate another settings, but I don�t understand the logic for some.
The one I understand is:
When you set fill = GridBagConstraints.BOTH then setting ipadx, ipady has no effect.
Is there any past discussion about this topic?
Thanks
AJ Dussault
Ranch Hand

Joined: May 17, 2000
Posts: 53
Marcela,
I spent two days playing around with this 'tutorial' when the light finally went on in my head concerning GridBagLayout. I now agree that is it THE layout to use. Good Luck!
http://nimbus.temple.edu/~jmillawa/GridBag/GridBag.html
Marcela Blei
Ranch Hand

Joined: Jun 28, 2000
Posts: 477
Thanks, I�ll take a look at it.
Marcela Blei
Ranch Hand

Joined: Jun 28, 2000
Posts: 477
AJ: I was trying the applet and it helped me a lot but I have the following doubts:
weightx and weighty: Which are the valid asigns values and what do each value mean?
gridwidth and gridheight: Which are the valid asigns values and what do each value mean? (except: RELATIVE & REMAINDER that I understand their meaning)
gridx and gridy: don�t return the results I expect, is there any another variable that conflicts with this setting?

AJ Dussault
Ranch Hand

Joined: May 17, 2000
Posts: 53
weightx and weighty - specifies how to handle the extra container space when the container is resized. try this: set the buttons ALL to weightx = 0 and weighty = 0. pick one button and set weightx and weighty to 1. Resize the container. What happens? what SHOULD happen is all the buttons stay the same size EXCEPT for the button you set to 1. what you just did is say 'ok - i want this ONE button to resize in both directions and none of the others'. now set your 1,1 button to .5,.5 and pick another button and set it to .5, .5. What do you expect to happen?
gridwidth and gridheight essentially tells your component how big you want it to be. pick one button and change the gridwidth and gridheight to 1,1. what happens? now set it to 2,2. what happens? now 3,3....what you should see is that button getting bigger and bigger.
gridx and gridy tell your component where you want it to live. pick button 10 and change gridx and gridy to 0,0. Does it disappear? Where do you think it is? It is probably sitting UNDER button 1. Change the size of button 10 and you might see it peeking out from underneath button 1.
What you need to do when you play with this tutorial is set ALL of the buttons to be exactly the same settings. That way as you change a single setting you can see what happens and start to predict the behavior.
Good luck. Let me know if you have more questions. I will be happy to try and help.
Aj
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: GridBagLayout