Awt Panel

Advertisements

Prev Tutorial Next Tutorial

Awt Panel

It is a predefined class used to provide a logical container to hold various GUI component. Panel always should exist as a part of frame.

Note: Frame is always visible to end user where as panel is not visible to end user.

Panel is a derived class of container class so you can use all the methods which is used in frame.

Syntax

Panel p=new Panel();
p.setBackground(Color.red);
p.setSize(400,300);

Example frame and panel

import java.awt.*;
class PanelFrame 
{
PanelFrame()
{
Frame f=new Frame();
f.setSize(600,400);
f.setBackground(Color.pink);
f.setLayout(new BorderLayout());

Panel p1=new Panel();
p1.setBackground(Color.cyan);
Label l1 =new Label("Enter Uname");
TextField tf1=new TextField(15);
Label l2=new Label("Enter Passward");
TextField tf2=new TextField(15);
p1.add(l1);
p1.add(tf1);
p1.add(l2);
p1.add(tf2);
f.add("North",p1);

Panel p2=new Panel();
p2.setBackground(Color.yellow);
Button b1=new Button("Send");
Button b2=new Button("Clear");
p2.add(b1);
p2.add(b2);
f.add("South",p2);
f.setVisible(true);
}

public static void main(String[] args) 
{
PanelFrame pf=new PanelFrame();	
}
}

Download code Click

panel frame example
Prev Tutorial Next Tutorial

Google Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements