0% found this document useful (0 votes)
1 views9 pages

Advane Java Practicals

The document contains Java code examples for creating GUI applications using AWT components. It includes programs demonstrating the use of Radio Buttons, Checkboxes, Text Fields, Text Areas, and Buttons, as well as List components for selecting multiple items. Each example is structured to create a simple user interface for various functionalities such as course selection, form submission, and city or newspaper selection.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views9 pages

Advane Java Practicals

The document contains Java code examples for creating GUI applications using AWT components. It includes programs demonstrating the use of Radio Buttons, Checkboxes, Text Fields, Text Areas, and Buttons, as well as List components for selecting multiple items. Each example is structured to create a simple user interface for various functionalities such as course selection, form submission, and city or newspaper selection.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

PR1

[Link] code
Q.1. Design applet/application to demonstrate the use of Radio Button and Checkbox.
Ans->

import [Link].*;
class checkradio{
public static void main(String[] args) {
Frame fr= new Frame();
[Link](400,300);
[Link](null);
[Link](true);
Label l1 = new Label("Select your course:");
[Link](50,50,120,50);
CheckboxGroup cbg = new CheckboxGroup();
Checkbox cb1= new Checkbox("Java",cbg,false);
[Link](50,100,50,50);
Checkbox cb2= new Checkbox("Python",cbg,false);
[Link](50,150,70,50);
Checkbox cb3= new Checkbox("Android",cbg, false);
[Link](50,200,70,50);
[Link](l1);
[Link](cb1);
[Link](cb2);
[Link](cb3);
Label l2 = new Label("Choose OS:");
[Link](250,50,100,50);
Checkbox cb4= new Checkbox("Windows");
[Link](250,100,100,50);
Checkbox cb5= new Checkbox("IOS");
[Link](250,150,100,50);
Checkbox cb6= new Checkbox("Linux");
[Link](250,200,100,50);
[Link](l2);
[Link](cb4);
[Link](cb5);
[Link](cb6); }
}

Output:

Q.2 Design applet/application to create form using Text Field, Text Area, Button and Label.
Ans->

import [Link].*;
class form
{
public static void main(String[] args)
{
Frame fr = new Frame("Form");
[Link](350,300);
[Link](null);
[Link](true);
Label L1 = new Label("Enter your name: ");
[Link](50,50,100,20);
TextField input = new TextField();
[Link](160,50,100,20);
[Link](L1);
[Link](input);
Label L2 = new Label("Enter your address: "); [Link](50,100,110,20);
TextArea input1 = new TextArea(10,20);
[Link](L2);
[Link](input1);
Button B1 = new Button("Submit");
[Link](150,230,100,30);
[Link](B1);
}
}

Output:
XIII. Exercise
Q.1. Develop a program using Label to display message “Welcome to Java”
Ans
import [Link].*;
public class Demo
{
public static void main(String args[])
{
Frame f= new Frame();
[Link](400,400);
[Link](true);
[Link](new FlowLayout());
Label l=new Label("Welcome to Java");
}
}
Output :
Q.2. Develop a program to select multiple languages known to user.(e.g. Marathi, Hindi,
English, Sanskrit).
Ans
import [Link].*;
class select
{
public static void main(String args[])
{
Frame f= new Frame();
[Link](400,400);
[Link](true);
[Link](new FlowLayout());
CheckBox cb1=new CheckBox(“Marathi”,true);
CheckBox cb2=new CheckBox(“Hindi”,true);
CheckBox cb3=new CheckBox(“English”,true);
CheckBox cb4=new CheckBox(“Sanskrit”,true);
[Link](cb1);
[Link](cb2);
[Link](cb3);
[Link](cb4);
}
}

Output :
Q.3 Write program to create three buttons with caption OK, RESET, and CANCEL.
Ans
import java .awt.*;
public class Demo
{
public static void main (string args[])
{
Frame f= new Frame();
[Link](400,400);
[Link](true);
[Link](new FlowLayout());
Button b1 = new Button(“OK”);
Button b2 = new Button(“RESET”);
Button b3 = new Button(“CANCEL”);
[Link](b1);
[Link](b2);
[Link](b3);
}
}
Output:
PR2
XIII. Exercise
Q.1 Develop an applet/application using List components to add names of 10 different cities.
Ans
import [Link].*;
public class city
{
public static void main (String args[])
{

Frame f= new Frame();


[Link](400,400);
[Link](true);
[Link](new FlowLayout());

List l=new List(10);


[Link]("pune");
[Link]("mumbai");
[Link]("solapur");
[Link]("goa");
[Link]("nashik");
[Link]("delhi");
[Link]("dhule");
[Link]("yzak");
[Link]("kolhapur");
[Link]("gangapur");

[Link](l);
}
}
Output:

Q.2 Develop applet/applicaton to select multiple names of news papers.


Ans
import [Link].*;
public class Sselection
{
public static void main (String args[])
{

Frame f= new Frame();


[Link](400,400);
[Link](true);
[Link](new FlowLayout());

List l=new List(4);

[Link](true);

[Link]("Times of India");
[Link]("Hindustan Times");
[Link]("The Economics Times");
[Link]("The Indin Express");
[Link](l);

}
}
Output:

You might also like