1.3.2 AWT Controls & Layout Manager Part-8
1.3.2 AWT Controls & Layout Manager Part-8
}
/* <applet code=ScrollbarExample width=200 height=300> </applet> */
}
/* <applet code=ScrollbarExample width=200 height=300> </applet> */
Constructors-
1. Panel()- Creates a new panel using the default layout manager.
2. Panel(LayoutManager layout)-Creates a new panel with the specified layout
manager.
setSIze(),setBounds(),setForeground()setbackground(),setFont() etc
Program- Develop a program to add Panel on Frame
import java.awt.*;
public class PanelExample {
PanelExample() {
Frame f= new Frame("Panel Example");
Panel panel1=new Panel();
panel.setBounds(40,80,200,200);
panel.setBackground(Color.gray);
Button b1=new Button("Button 1");
b1.setBounds(50,100,80,30);
b1.setBackground(Color.yellow);
Button b2=new Button("Button 2");
b2.setBounds(100,100,80,30);
b2.setBackground(Color.green);
panel1.add(b1); panel1.add(b2);
f.add(panel1);
f.setSize(400,400);
f.setLayout(null);
f.setVisible(true);
}
public static void main(String args[]) { new PanelExample(); } }
Note- compile using javac PanelExample.java and execute it by PanelExample.java