AYush Practical No 1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Advance Java Programming

---------------------------------------------------------------------------
Name :- Ayush Maroti Wadje Class :-CO5I
Roll No :- 75
------------------------------------------------------------------------------------------------
Practical No 1 :- Write a program to demonstrate the use of AWT
components
X. -------- ?
1. Design an applet/application to demonstrate the use of radio Button and
CheckBox.

Code:-
import java.awt.*;
class Prog_code_pr1
{
public static void main(String args[])
{
Frame fr = new Frame("Practical 1 ");
fr.setSize(400,450);
fr.setVisible(true);
fr.setLayout(new FlowLayout());
Label l1 = new Label("Select your Favourite Friend : ");
Label l2 = new Label("Select your Gender : ");
Checkbox ch1 = new Checkbox("Ayush");
Checkbox ch2 = new Checkbox("sai");
Checkbox ch3 = new Checkbox("Anju");
Checkbox ch4 = new Checkbox("Puja");

CheckboxGroup cbg = new CheckboxGroup();


Checkbox cha = new Checkbox("Male",cbg,true);
Checkbox chb = new Checkbox("Female",cbg,false);
fr.add(l1);
fr.add(ch1);
fr.add(ch2);
fr.add(ch3);
fr.add(ch4);

fr.add(l2);
fr.add(cha);
fr.add(chb);
}
}

Output :-
2. Design an applet /application to create form using Text Field, text Area,
Button and Label.

Code :-
import java.awt.*;
public class aysuush
{
public static void main(String args[])
{
Frame fr = new Frame("Java Practical 1 ");
fr.setSize(400,450);
fr.setVisible(true);
fr.setLayout(new FlowLayout());
Label l1 = new Label("Enter Your Name : ");
Label l2 = new Label("Enter your address/Location : ");
TextField t1 = new TextField(30);
TextArea t2 = new TextArea(20,40);
Button b1 = new Button("Confirm");
fr.add(l1);
fr.add(t1);
fr.add(l2);
fr.add(t2);
fr.add(b1);
}
}

Output :-
XIII. Exercise.
1. Develop a program using Label to display message “Welcome to Java”

Code :-
import java.awt.*;
class Disp_Msg
{
public static void main(String args[])
{
Frame fr = new Frame(" Java Practical 1");
fr.setSize(400,450);
fr.setLayout(new FlowLayout());
fr.setVisible(true);
Label l1 = new Label("Welcome to Java");
fr.add(l1);
}
}
Output :-
2. Develop a program to select multiple language known to user. (e.g
Marathi, Hindi, Hindi, English, Sanskrit)
Code :-
import java.awt.*;
class Use_Check_bx
{
public static void main(String args[])
{

Frame fr = new Frame("Select Multiple Hobbies");


fr.setLayout(new FlowLayout());
fr.setVisible(true);
fr.setSize(400,200);
Label l1 = new Label("Select Your Hobbies : ");
Checkbox bx1 = new Checkbox("Sport");
Checkbox bx2 = new Checkbox("Drawing");
Checkbox bx3 = new Checkbox("Traveling");
Checkbox bx4 = new Checkbox("reading");
Checkbox bx5 = new Checkbox("photography");

fr.add(l1);
fr.add(bx1);
fr.add(bx2);
fr.add(bx3);
fr.add(bx4);
fr.add(bx5);

}
}

Output :-
3. Write a program to create three Buttons with Captions OK, RESET And
CANCEL.

Code :-
import java.awt.*;
class Use_Button_Exe
{
public static void main(String args[])
{
Frame fr = new Frame(" java Practical 1");
fr.setSize(400,250);
fr.setLayout(new FlowLayout ());
fr.setVisible(true);
Button b1 = new Button("OK");
Button b2 = new Button("RESET");
Button b3 = new Button("CANCEL");
fr.add(b1);
fr.add(b2);
fr.add(b3);
}
}
Output :-

You might also like