Type Here to Get Search Results !

Practical No 1: Write a program to demonstrate the use of AWT components

 PRACTICAL NO 1 :   WRITE A PROGRAM TO DEMONSTRATE THE USE OF AWT COMPONENTS.


1)  Design an applet/application to demonstrate the use of Radio Button and Checkbox

// demonstrate Radio button


import java.awt.*;
class RadioButton extends Frame
{
	RadioButton()
	{
		setBackground(Color.cyan);
		FlowLayout f1=new FlowLayout();
		setLayout(f1);
		CheckboxGroup cbg=new CheckboxGroup();
		Checkbox c1=new Checkbox("Male",false,cbg);
		Checkbox c2=new Checkbox("Female",false,cbg);
		
		add(c1);
		add(c2);

	}
	public static void main(String args[])
	{
		RadioButton rb1=new RadioButton();
		rb1.setVisible(true);
		rb1.setTitle("Radio Button");
		rb1.setSize(500,500);
	}
}  

OUTPUT :

Design an applet/application to demonstrate the use of Radio Button and Checkbox


2) Design an applet/application to create form using Text Field, Text Area, Button and Label.

import java.awt.*;
class LoginFormDemo1 extends Frame 
{
	Label l4;
	TextField tf1,tf2;
	LoginFormDemo1()
	{

		setLayout(null);
		Label l1=new Label("LOGIN FORM");
		l1.setFont(new Font("Times New Roman",Font.BOLD,20));
		l1.setForeground(Color.red);
		l1.setBounds(220,70,130,30);

		Label l2=new Label("USERNAME :");
		l2.setFont(new Font("Copperplate Gothic Bold",Font.BOLD,15));
		l2.setBounds(130,150,100,30);

		Label l3=new Label("PASSWORD :");
		l3.setFont(new Font("Copperplate Gothic Bold",Font.BOLD,15));
		l3.setBounds(130,200,100,30);

		l4=new Label("              ");
		l4.setBounds(170,340,400,30);
		l4.setFont(new Font("Copperplate Gothic Bold",Font.BOLD,20));
		l4.setForeground(Color.green);

		tf1=new TextField(20);
		tf1.setFont(new Font("Times New Roman",Font.PLAIN,13));
		tf1.setBounds(270,150,150,30);

	    tf2=new TextField(20);
		tf2.setFont(new Font("Times New Roman",Font.PLAIN,13));
		tf2.setBounds(270,200,150,30);
		tf2.setEchoChar('*');

		Button b1=new Button("SIGN IN");
		b1.setFont(new Font("Copperplate Gothic Bold",Font.BOLD,15));
		b1.setBackground(Color.yellow);
		b1.setBounds(220,270,100,30);

		add(l1);
		add(l2); add(tf1);
		add(l3); add(tf2);
		add(b1); add(l4);
	}
	public static void main(String args[])
	{

		LoginFormDemo1 ld1=new LoginFormDemo1();
		ld1.setVisible(true);
		ld1.setSize(600,400);
		ld1.setTitle("LOGIN FORM");
}
}
 

OUTPUT :

Design an applet/application to create form using Text Field, Text Area, Button and Label.


Write a program todemonstrate the use ofAWT components likeLabel, Textfield,TextArea, Button,Checkbox, RadioButtonetc

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.

Below Post Ad