**************************************************************************
COMPLETE SOURCE CODE FOR : CreateListUsingJList.java
**************************************************************************
import javax.swing.JList;
import javax.swing.JFrame;
import java.awt.FlowLayout;
public class CreateListUsingJList
{
public static void main(String[]args)
{
//Create contents for JList using array
//Using String as array type
String[]listContents={"HI","HA","HU"};
//Create a list using JList
JList list=new JList(listContents);
//Create a JFrame that will be use to put JList into it
JFrame frame=new JFrame("Create list using JList");
//set JFrame layout to FlowLayout
frame.setLayout(new FlowLayout());
//add created JList into JFrame
frame.add(list);
//set default close operation for JFrame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//set JFrame size
frame.setSize(400,400);
//make JFrame visible. So we can see it
frame.setVisible(true);
}
}
**************************************************************************
JUST COMPILE AND EXECUTE IT
**************************************************************************