Swing

Create a JList Component in java,how to create JList in java
Previous Home Next

 

The JList  Control is the GUI Based tool Which is allow to insert multiple item in a single list and display multiple column in a single list. The list is used to select items from the item group like combo box but the JList and Combo box has major different between them. in Combo box we can select only one item at a time but JList allow to select multiple number of the item

 

 
package r4r;
import javax.swing.*;
public class JListtest {
	public static void main(String[] args) {
		  String sub[] = {"Math", "Biology", "Phisics", "Chemestry"};
		  JFrame frame = new JFrame("Creating a JList Components");
		  JPanel panel = new JPanel();
		  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		  JList lst = new JList(sub);
		  frame.setUndecorated(true);
		  frame.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
		  panel.add(lst);
		  frame.add(panel);
		  frame.setSize(500,500);
		  frame.setVisible(true);
		  }
}


Previous Home Next