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

PracticalNo6_1

The document outlines a practical assignment for creating a Java program using Swing to display a JScrollPane and JComboBox in an JApplet. The program allows users to select a city from a JComboBox and displays the selected city in a JLabel. The student, Mavani Ashish Shantilal, is assigned roll number 47 and the program includes necessary imports and event handling for the JComboBox.

Uploaded by

Ashish Mavani
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)
5 views

PracticalNo6_1

The document outlines a practical assignment for creating a Java program using Swing to display a JScrollPane and JComboBox in an JApplet. The program allows users to select a city from a JComboBox and displays the selected city in a JLabel. The student, Mavani Ashish Shantilal, is assigned roll number 47 and the program includes necessary imports and event handling for the JComboBox.

Uploaded by

Ashish Mavani
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