Source Code : How to use the list component
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
How to use the list component

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
public class ListTest extends JFrame implements ListSelectionListener {
JLabel label = new JLabel("The fox jumps over the lazy dog.");
public ListTest() {
setTitle("ListTest: Press control to multi-select");
setSize(400, 300);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
String[] words = { "quick", "brown", "hungry", "wild", "silent", "huge" };
JList wordList = new JList(words);
JScrollPane scrollPane = new JScrollPane(wordList);
JPanel p = new JPanel();
p.add(scrollPane);
wordList.addListSelectionListener(this);
getContentPane().add(p, "South");
getContentPane().add(label, "Center");
}
public void valueChanged(ListSelectionEvent evt) {
JList source = (JList) evt.getSource();
Object[] values = source.getSelectedValues();
String text = "";
for (int i = 0; i < values.length; i++) {
String word = (String) values[i];
text += word + " ";
}
label.setText("The " + text + "fox jumps over the lazy dog.");
}
public static void main(String[] args) {
JFrame frame = new ListTest();
frame.show();
}
}
Thank with us