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 / January 2005

Tip: Looking for answers? Try searching our database.

gridbagconstraints problem

Thread view: 
alun Groome - 29 Jan 2005 17:30 GMT
Hi ,

im trying to use a gridbag constraing layout.

I want to add 2 Jpannels and 2 Jbuttons.  But the panels do not appear on the screen just the buttons.    All other layout managers add my panels fine.

any ideas?
JInternalFrame fr1 =
     new JInternalFrame("app", true, true);
 fr1.setBounds(0, 05, 900, 900);
 Container cn = fr1.getContentPane();
 cn.setLayout(new GridBagLayout());

 GridBagConstraints c = new GridBagConstraints();

c.gridx=0;
c.gridy=0;
cn.add(a,c); //button
 
c.gridx=0;
c.gridy=1;
cn.add(b,c); //button
 
c.gridx=0;
c.gridy=2;
cn.add(ca,c);  //button

c.gridx=0;
c.gridy=3;
cn.add(a,c);   //button
 
c.gridx=1;
c.gridy=1;
cn.add(panelb,c); //panel

c.gridx=1;
c.gridy=2;
cn.add(panela,c); //panel
elmar.schraml@gmail.com - 31 Jan 2005 07:03 GMT
Off the top of my head, just some suggestions;

- Is everything all right withe the Panels? ( Instantiated, not empty,
panels' children not empty or of 0 size?)
- try putting something invisible (i.e. a JLabel with an empty String
as content) into the cells of the GridBagLayout that you are levaing
empty at the moment
- you should add a line before the cn.add( ) operations like
cn.setConstraints(panelb,c);

Hope that helps,
Elmar


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.