This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I'm building a gui using a jframe as the base window and adding jpanel's to the frame using a gridbaglayout manager. The gridbaglayout is a single column with 5 rows; a jlabel with image and four jpanel's.The first jpanel is a nested panel with 2 borderlayout panels each with 2 flowlayout panels. My problem is the last panel is not visible when i run the application. If i resize the window the panel is there. I've tried adjusting the jframe height, row & column weights in the gridbagconstraints & removing/repositioning panels. If i remove or reposition the jlabel w/image then only the first two jpanels are visible; the same happens if i remove or reposition any of the other jpanels.
Can someone provide some assistance! Any help would be greatly appreciated. Following is some of my code.
Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.
Please edit your profile and correct your display name since accounts with incorrect display names will be deleted.
Joined: Dec 30, 2003
Thanks for your assistance, the code you provided worked. However, it would be helpful if you could explain why the GridBag RELATIVE setting for c.gridy &/or c.gridheight did not work. According to "Complete Java 2 Certification" if I'm filling the layout from top-left to bottom-right one row at a time, I should be able to set my Constraints one time using the RELATIVE/REMAINDER values.
Joined: Jun 09, 2003
the docs say it should work, but go on to say:
"We recommend specifying the gridx and gridy values for each component; this tends to result in more predictable layouts."