0% found this document useful (0 votes)
2 views5 pages

Practical 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views5 pages

Practical 1

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

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

and Checkbox.

import java.awt.*;
public class question1
{
public static void main(String args[])
{
Frame f=new Frame();
f.setSize(500,500);
f.setTitle("Registration Page");
f.setLayout(new FlowLayout());
Label l=new Label("Select Gender:");
f.add(l);
CheckboxGroup cr=new CheckboxGroup();
Checkbox c1=new Checkbox("Male",cr,false);
Checkbox c2=new Checkbox("Female",cr,true);
f.add(c1);
f.add(c2);
Checkbox c3=new Checkbox("I Agree");
f.add(c3);
f.setVisible(true);
}
}

Output:

>Design an applet/application to create form using Text Field,Text Area,


Button and Label
import java.awt.*;
public class question2 {
public static void main(String args[])
{

MADHURA MAHESH INGAWALE 2251


Frame f=new Frame();
f.setSize(500,500);
f.setTitle("Registration Page");
f.setLayout(new FlowLayout());
f.setVisible(true);
Label l1=new Label("Enter Name:");
f.add(l1);
TextField t1=new TextField(20);
f.add(t1);
Label l4=new Label("Enter Adress:");
f.add(l4);
TextArea t4=new TextArea(4,50);
f.add(t4);
Label l2=new Label("Enter Email:");
f.add(l2);
TextField t2=new TextField(20);
f.add(t2);
Label l3=new Label("Enter Phone no:");
f.add(l3);
TextField t3=new TextField(20);
f.add(t3);
Button b1=new Button("Submit");
f.add(b1);
}

Output:

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

import java.awt.*;

MADHURA MAHESH INGAWALE 2251


public class question3 {
public static void main(String args[])
{
Frame f=new Frame();
f.setSize(500,500);
f.setLayout(new FlowLayout());
Label l1=new Label("Welcome to Java");
f.add(l1);
f.setVisible(true);
}
}

Output:

2.Develop a program to select multiple languages known to user.(e.g


Marathi,Hindi,English,Sanskrit).
import java.awt.*;
public class question4 {
public static void main(String args[])
{
Frame f=new Frame();
f.setSize(500,500);
f.setLayout(new FlowLayout());
Label l=new Label("Select known languages");
f.add(l);
Checkbox c1=new Checkbox("Marathi");
f.add(c1);
Checkbox c2=new Checkbox("Hindi");
f.add(c2);
Checkbox c3=new Checkbox("English");
f.add(c3);
Checkbox c4=new Checkbox("Sanskrit");
f.add(c4);

MADHURA MAHESH INGAWALE 2251


f.setVisible(true);

}
}

Output:

3.Write a program to create three Buttons with Caption OK, RESET and
CANCEL.
import java.awt.*;
public class question5 {
public static void main(String args[])
{
Frame f=new Frame();
f.setSize(500,500);
// f.setTitle("Registration Page");
f.setLayout(new FlowLayout());
f.setVisible(true);
Button b1=new Button("OK");
f.add(b1);
Button b2=new Button("RESET");
f.add(b2);
Button b3=new Button("CANCEL");
f.add(b3);
}
}

Output:

MADHURA MAHESH INGAWALE 2251


MADHURA MAHESH INGAWALE 2251

You might also like