Professional Documents
Culture Documents
in Java
By,
Asmatullah Khan,
CL/CP, GIOE,
Secunderabad.
Contents
1. List and discuss AWT classes
7. Explain AWT controls and handlings – labels, buttons, checkboxes, lists, scrollbars, Text fields, text area, menus, dialog
boxes.
9. Discuss about The Delegation event model – events, event sources and event Listeners
• An AWT Applet (in package java.applet) is
the top-level container for an applet, which is
a Java program running inside a browser.
• An Anonymous Instance
▫ You can create a Label without specifying an identifier, called anonymous instance.
▫ In the case, the Java compiler will assign an anonymous identifier for the allocated object.
▫ You will not be able to reference an anonymous instance in your program after it is created.
Example – Frame Creation
import java.awt.*;
class FrameDemo {
public static void main(String[] args)
{
Frame f=new Frame();
f.setTitle("myframe");
f.setBackground(Color.cyan);
f.setForeground(Color.red);
f.setLayout(new FlowLayout());
public AddEmployee() {
setTitle("Employee Detail");
setBackground(Color.cyan);
setLayout(null);
add(fn);
add(ftn);
add(DOB);
add(gender);
add(address);
add(country);
add(mobile);
f_name=new TextField("",20);
Father1=new TextField("",20);
dob=new TextField("Day/Month/Year",20);
add1=new TextField("",40);
mobile_no=new TextField("",20);
f_name.setBounds(200,60,200,20);
Father1.setBounds(200,110,200,20);
dob.setBounds(200,160,140,20);
add1.setBounds(200,260,200,20);
mobile_no.setBounds(200,360,130,20);
add(f_name);
add(Father1);
add(dob);
cg1=new CheckboxGroup();
male=new Checkbox("Male", cg1, true);
female=new Checkbox("Female", cg1, false);
add(male); add(female);
male.setBounds(200,200,50,50);
female.setBounds(300,200,60,50);
add(add1);
c=new Choice();
c.addItem("City");
c.addItem("New Delhi");
c.addItem("Raipur");
c.addItem("Chandigarh");
c.addItem("Dehradun");
c.addItem("Patna");
c.addItem("Dispur");
c.addItem("Other");
c.setBounds(200,310,130,20);
add(c); add(c); add(c); add(c); add(c); add(c); add(c); add(c); add(c); add(c); add(c); add(c);
add(c); add(mobile_no);
Font fa=new Font("Arial", Font.BOLD, 15);
b1=new Button("Submit");
b2=new Button("Exit");
b3=new Button("AddNew");
b1.setBounds(170,430,80,30);
b2.setBounds(270,430,80,30);
b3.setBounds(370,430,80,30);
b1.setBackground(Color.pink);
b2.setBackground(Color.pink);
b3.setBackground(Color.pink);
b1.setFont(fa);
b2.setFont(fa);
b3.setFont(fa);
setSize(600,500);
setVisible(true);
} //cons
} // class
class Employee {
public static void main(String s[]) {
AddEmployee obj=new AddEmployee(); } }
Java adopts the so-called "Event-Driven" (or "Event-Delegation") programming
model for event-handling, similar to most of the visual programming languages
(such as Visual Basic and Delphi).
Default for the content panes of JFrame and JApplets. Arranges the components into five
Border areas: North, South, East, West, and Center
Layout Components are positioned in a five different areas: North, South, East, West or Center. If you do not
specify a particular area the other areas will use this space by expanding.