Pratical 1
[Link] use of radiobutton and check box.
import [Link].*;
import [Link].*;
public class CheckRadio extends Frame
{
CheckRadio()
{
CheckboxGroup rb = new CheckboxGroup();
Checkbox cb = new Checkbox("java",rb,false);
[Link](80,80,60,50);
add(cb);
Checkbox cb1 = new Checkbox("Python",rb,false);
[Link](80,120,60,50);
add(cb1);
Label l1 = new Label("Check Box start here!");
add(l1);
[Link](80,160,60,50);
Checkbox cb2 = new Checkbox("C++");
[Link](80,200,60,50);
add(cb2);
Checkbox cb3 = new Checkbox("Java");
[Link](80,240,60,50);
add(cb3);
setSize(400,400);
setTitle("Pankaj");
setLayout(null);
setVisible(true);
}
public static void main(String args[])
{
CheckRadio cr = new CheckRadio();
}
}
Q. to create form using Textfield, Textarea, Button, Label
import [Link].*;
import [Link].*;
public class Demo extends Frame
{
Demo()
{
Button b1 = new Button("Submit");
add(b1);
[Link](80,240,60,50);
Label l1 = new Label("Welcome to form",[Link]);
add(l1);
[Link](100,80,100,50);
TextField t1 = new TextField("Enter your Name");
add(t1);
[Link](80,180,120,50);
TextArea ta = new TextArea("Welcome Java",2,3);
add(ta);
[Link](80,300,120,50);
setSize(200,200);
setLayout(null);
setVisible(true);
setTitle("Pankaj");
}
public static void main(String args[])
{
Demo d = new Demo();
}
}
[Link] using label to display “welcome to java”.
import [Link].*;
import [Link].*;
public class label extends Frame
{
label()
{
Label l1 = new Label("Welcome to Java");
add(l1);
[Link](100,80,150,60);
setSize(200,200);
setVisible(true);
setLayout(null);
setTitle("Pankaj");
}
public static void main(String args[])
{
label l2 = new label();
}}
Q. Program to create a three Buttons.
import [Link].*;
import [Link].*;
public class button extends Frame
{
button()
{
Button b1 = new Button("OK");
add(b1);
[Link](80,80,60,50);
Button b2 = new Button("RESET");
add(b2);
[Link](80,140,60,50);
Button b3 = new Button("CANCEL");
add(b3);
[Link](80,200,60,50);
setSize(200,200);
setLayout(null);
setVisible(true);
setTitle("Pankaj");
}
public static void main(String []args)
{
button bb = new button();
}}
[Link] to select multiple languages.
import [Link].*;
import [Link].*;
public class Name extends Frame
{
Name()
{
Checkbox cb = new Checkbox("Marathi");
add(cb);
[Link](100,150,60,50);
Checkbox cb1 = new Checkbox("Sanskrit");
add(cb1);
[Link](100,190,60,50);
Checkbox cb2 = new Checkbox("Hindi");
add(cb2);
[Link](100,240,60,50);
Checkbox cb3 = new Checkbox("English");
add(cb3);
[Link](100,280,60,50);
setSize(200,200);
setLayout(null);
setVisible(true);
setTitle("Pankaj");
}
public static void main(String []args)
{
Name n = new Name();
}
}
Pratical 2
Q. write java program to show following output.
import [Link].*;
import [Link].*;
public class list extends Frame
{
list()
{
List l1 = new List(3,false);
[Link]("Summer");
[Link]("Rainy");
[Link]("Winter");
add(l1);
[Link](100,120,150,60);
setSize(200,200);
setVisible(true);
setLayout(null);
setTitle("Pankaj");
}
public static void main(String args[])
{
list l2 = new list();
}
}
[Link] name of 10 cities in list component.
import [Link].*;
import [Link].*;
public class list1 extends Frame
{
list1()
{
List l1 = new List(10,false);
[Link]("MUMBAI");
[Link]("THANE");
[Link]("KOLHAPUR");
[Link]("DHULE");
[Link]("NASHIK");
[Link]("CHHATRAPATI SAMBHAJI NAGAR");
[Link]("PUNE");
[Link]("RAIGAD");
[Link]("AHMEDNAGAR");
[Link]("NANDURBAR");
add(l1);
[Link](150,160,150,200);
setSize(200,200);
setVisible(true);
setLayout(null);
setTitle("Pankaj");
}
public static void main(String args[])
{
list1 li = new list1();
}
}
[Link] multiple news paper using list component.
import [Link].*;
import [Link].*;
public class list2 extends Frame
{
list2()
{
List l1 = new List();
[Link]("LOKMAT");
[Link]("KESARI");
[Link]("MAHARASHTRA TIMES");
[Link]("TIMES OF INDIA");
[Link]("DAINIK BHASKAR");
[Link]("HINDUSTAN");
[Link]("INDIAN EXPRESS");
[Link]("SAMNA");
add(l1);
[Link](100,120,190,100);
setSize(200,200);
setVisible(true);
setLayout(null);
setTitle("Pankaj");
}
public static void main(String args[])
{
list2 l2 = new list2();
}
}