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

PROGRAM6

The document provides a Java program that demonstrates a multiple selection list box using Swing components. It creates a JFrame with a JList for selecting programming languages and a button to submit the selection, which is then displayed in another JList. The program allows users to select multiple languages and view their choices in a separate list upon clicking the submit button.

Uploaded by

joyalprincess
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)
1 views

PROGRAM6

The document provides a Java program that demonstrates a multiple selection list box using Swing components. It creates a JFrame with a JList for selecting programming languages and a button to submit the selection, which is then displayed in another JList. The program allows users to select multiple languages and view their choices in a separate list upon clicking the submit button.

Uploaded by

joyalprincess
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/ 3

PROGRAM-6

Write a Java Program To Demonstrate the Multiple Selection List Box


SOURCE CODE
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class jframe implements ActionListener
{ JFrame jf;
JButton b1,b2;
JLabel L1;
JList list1,list2;
public jframe()
{ jf=new JFrame("Multiple Selection ListBox");
jf.setLayout(new FlowLayout());
String values[]={"C","C++","Java","Python","R","HTML","XML","CSS","PHP"};
L1= new JLabel("Which Languages do you know?");
//add the above array in to List1
list1 = new JList(values);
//creating empty list
list2 = new JList();
//for selecting multiple option from list

list1.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
b1=new JButton("Submit");
b1.addActionListener(this);
jf.add(L1);
jf.add(new JScrollPane(list1));
jf.add(list1);
jf.add(b1);
jf.add(new JScrollPane(list2));
jf.add(list2);
jf.setVisible(true);
jf.setSize(700,500);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getActionCommand().equals("Submit"))
{
list2.setListData(list1.getSelectedValues());
}
}
}
class PL6
{
public static void main(String args[])
{
jframe j=new jframe();
}
}
PROGRAM-6-OUTPUT

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy