Panel class in java
Panel class
-------------
This class is used to divide the
window into various sub-section , each section is used as a panel or we can say
is reffered as a panel .
The
general form of creating the panel is ,
Panel
objectname=new Panel()
import java.applet.*;
import java.awt.*;
/*
<applet
code="PanelDemo" height=200 width=200>
</applet>
*/
public class PanelDemo extends
Applet
{
public
void init()
{
setLayout(new
BorderLayout());
Panel
p1=new Panel();
TextField
tf=new TextField(20);
p1.add(tf);
add(p1,"North");
Panel
p2=new Panel();
p2.setLayout(new
GirdLayout(5,4));
for(int
i=1;i<=20;i++)
{
p2.add(new
Button("Button"+i));
}
add(p2,"Center");
Panel
p3=new Panel();
Label
l=new Label("Welcome To World To Panel");
p3.add(l);
add(p3,"South");
}
public
Insets getInsets()
{
return
new Insets(5,5,5,5);
}
}
Comments
Post a Comment