Discussion Locked

JPanel Layout

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

i have JFrame where i have numbers of JPanel in borderlayout...is it possible to setLayout(null) to each JPanel?? if yes can u give me short example...

thanks in advance..
Ashish

6 replies

by diva_cen2000

hi,

As u know every Container is having a method
setLayout(instance of a Layout).with this method
u can override the default layout of a container
so using the refreneces created for JPanel call
this method set the Layout to null.

eg:

JPanel p=new JPanel();
p.setLayout(null);
then add the panel to the JFrame.
this is it
with regards
divas...

by sps19742001

Hi,
It is possible to set theie own Layout to each panel.

Example,

public class ExampleFrame extends JFrame
{
JPanel Npanel = new JPanel();
JPanel Spanel = new JPanel();
JPanel Wpanel = new JPanel();
JPanel Epanel = new JPanel();
JPanel panel1 = new JPanel();

public ExampleFrame()
{
NPanel.setLayout(null);
SPanel.setLauout(null);
WPanel.setLayout(null);
EPanel.setLayout(null);
this.getContentPane().add(NPanel,BorderLayout.NORTH);
this.getContentPane().add(SPanel,BorderLayout.SOUTH);
this.getContentPane().add(WPanel,BorderLayout.CENTER);
this.getContentPane().add(EPanel,BorderLayout.EAST);

}
}

This discussion is closed to new replies.