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