0% found this document useful (0 votes)
3 views

JAVA practical 14

The document contains Java code examples for creating various GUI applications using AWT components. It includes implementations for a list of cities, a multi-selection list for newspapers, buttons for OK, RESET, and CANCEL, radio buttons and checkboxes, and a form with text fields and a button. Each example demonstrates the use of event listeners and window management in Java AWT.

Uploaded by

rajkirdath369
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)
3 views

JAVA practical 14

The document contains Java code examples for creating various GUI applications using AWT components. It includes implementations for a list of cities, a multi-selection list for newspapers, buttons for OK, RESET, and CANCEL, radio buttons and checkboxes, and a form with text fields and a button. Each example demonstrates the use of event listeners and window management in Java AWT.

Uploaded by

rajkirdath369
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/ 11

PRACTICAL 14

*/ DEVELOP APPLET/APPLICATION USING LIST COMPONENTS TO ADD


NAMES OF 10 DIFFERENT CITIES :-
import java.awt.*;
import java.awt.event.*;
class Listdemo extends Frame
{
List l;
Listdemo()
{
setVisible(true);
setSize(500,500);
l=new List(5);
l.add("Chhatrapati Sambahaji Nagar");
l.add("Kolhapur");
l.add("Mumbai");
l.add("Nashik");
l.add("Nagpur");
l.add("Pune");
l.add("Satara");
l.add("Sangali");
l.add("Solapur");
l.add("Ratnagiri");
add(l);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
dispose();
}
});
}
public static void main(String args[])
{
Listdemo l1=new Listdemo();
}
}
OUTPUT:-
*/ DEVELOP APPLET/APPLICATION TO SELECT MULTIPLE NAMES OF
NWES PAPERS:-

import java.awt.*;
import java.awt.event.*;
class Listmul_demo extends Frame
{
List l;
Listmul_demo()
{
setVisible(true);
setSize(500,500);
l=new List(5,true);
l.add("Amar Ujala");
l.add("Dainik Jagran");
l.add("Dainik Bhaskar");
l.add("Eenadu");
l.add("Hindustan Times");
l.add("Malayala Manorama");
l.add("The Times of India");
add(l);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
dispose();
}
});
}
public static void main(String args[])
{
Listmul_demo l1=new Listmul_demo();
}
}
OUTPUT:-
*/WAP TO CREATE THREE BUTTONS WITH CAPTION ‘OK’, ‘RESET’ AND
‘CANCEL’ :-

import java.awt.event.*;
import java.awt.*;
class buttondemo extends Frame
{
Button b1,b2,b3;
buttondemo()
{
setVisible(true);
setSize(500,500);
setLayout(new FlowLayout());
b1=new Button("OK");
b2=new Button("RESET");
b3=new Button("CANCEL");
add(b1);
add(b2);
add(b3);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
dispose();
}
});
}
public static void main(String args[])
{
buttondemo bd=new buttondemo();
}
}
OUTPUT :-
*/ DESIGN AN APPLET/APPLICATION TO DEMONSTRATE THE USE OF
RADIOBUTTON AND CHECKBOX :-

import java.awt.*;
import java.awt.event.*;
class RadioCheckboxeg extends Frame implements ItemListener
{
CheckboxGroup cbg;
Checkbox c1,c2,c3,c4,c5,c6;
Label l1,l2,l3,l4;
RadioCheckboxeg()
{
cbg=new CheckboxGroup();
setVisible(true);
setSize(500,500);
setLayout(new GridLayout(4,4));
c1=new Checkbox("C ");
c2=new Checkbox("C++ ");
c3=new Checkbox("JAVA ");
c4=new Checkbox("Mr ",cbg,true);
c5=new Checkbox("Ms ",cbg,true);
c6=new Checkbox("Mrs",cbg,true);
c1.addItemListener(this);
c2.addItemListener(this);
c3.addItemListener(this);
c4.addItemListener(this);
c5.addItemListener(this);
c6.addItemListener(this);
l1=new Label();
l2=new Label();
l3=new Label();
l4=new Label();
add(c1);
add(c2);
add(c3);
add(l1);
add(l2);
add(l3);
add(c4);
add(c5);
add(c6);
add(l4);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
dispose();
}
});
}
public void itemStateChanged(ItemEvent ie)
{
String s1="C"+c1.getState();
l1.setText(s1);
String s2="C++"+c2.getState();
l2.setText(s2);
String s3="JAVA"+c3.getState();
l3.setText(s3);
Checkbox c=cbg.getSelectedCheckbox();
String s4=c.getLabel();
l4.setText("Selected Label : "+s4);
}
public static void main(String args[])
{
RadioCheckboxeg rc=new RadioCheckboxeg();
}
}

OUTPUT :-
*/ DESIGN AN APPLET / APPLICATION TO CREATE FORM USING
TEXTFILED,TEXT AREA ,BUTTON AND LABEL :-

import java.awt.*;
import java.awt.event.*;
class Textdemo1 extends Frame
{
TextField t1,t2;
Button b1;
Label l1,l2,l3;
String str;
Textdemo1()
{
setVisible(true);
setSize(500,500);
setLayout(new FlowLayout());
l1=new Label("Enter Name : ");
l2=new Label("Enter Enrollment : ");
l3=new Label("Enter Branch : ");
t1=new TextField(25);
t2=new TextField(15);
b1=new Button("SUBMIT");
TextArea ta=new TextArea(" ",2,30);
add(l1);
add(t1);
add(l2);
add(t2);
add(l3);
add(ta);
add(b1);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
dispose();
}
});
}

public static void main(String args[])


{
Textdemo1 td=new Textdemo1();
}
}
OUTPUT :-

You might also like