0% found this document useful (0 votes)
16 views2 pages

PracticalNo6 1

AJP Practical No. 6 - 1st code

Uploaded by

xamexi1077
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)
16 views2 pages

PracticalNo6 1

AJP Practical No. 6 - 1st code

Uploaded by

xamexi1077
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/ 2

Practical No.

: 06

Practical Name: Write a program using swing to display a ScrollPane and JComboBox in an
JApplet with the items – English, Marathi, Hindi, Sanskrit.

Roll No.: 47

Student Name: Mavani Ashish Shantilal

Program:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

class practical6_1
{
public static void main(String[] args)
{
JFrame f = new JFrame("Cities");
f.setVisible(true);
f.setSize(500,300);
f.setLayout(new FlowLayout());

JComboBox c = new JComboBox();


c.addItem("Solapur");
c.addItem("Pune");
c.addItem("Banglore");
c.addItem("Mumbai");

JLabel l = new JLabel();

c.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
String city = (String) c.getSelectedItem();
l.setText("You are in "+city);
}
});

f.add(c);
f.add(l);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
Output:

You might also like