JList box java

Ads
 

JList box java

We are going to describe JList box java. First of all we have created JList component of Swing. List is a component of GUI() Graphical User Interface.

We are going to describe JList box java. First of all we have created JList component of Swing. List is a component of GUI() Graphical User Interface.

JList box java

We are going to describe JList box java. First of all we have created JList component of Swing. List is a component of GUI() Graphical User Interface. It allows the multiple items in a list and In this class extend the JComponent class in Swing. We can use select item from the combo box because you can select more than one item at once from the list.

Example of JList:-

package List;

import javax.swing.*;

public class ListExample {
	public static void main(String[] args) {
		String list1[] = { "List", "List1", "List2", "List3" };
		JFrame frame = new JFrame("Creating a JList box");
		JPanel panel = new JPanel();
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		JList list = new JList(list1);
		frame.setUndecorated(true);
		frame.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
		panel.add(list);
		frame.add(panel);
		frame.setSize(300, 200);
		frame.setVisible(true);
	   }
     }

output:-

Download Source Code

Ads

Ads