public class List
extends Component
implements ItemSelectable, Accessible
Constructor | Description |
---|---|
List() | Used to create new scrolling list. |
List(int rows) | Creates a new scrolling list initialized with specified number of visible lines. |
List(int rows, boolean multipleMode) | Constructs a new scrolling list initialized to display the specified number of rows. |
//ListDemo.java
import java.awt.*;
import java.awt.event.*;
class ListDemo extends Frame implements ItemListener
{
Choice country;
public ListDemo(String title)
{
super(title);
setLayout(new FlowLayout());
country = new Choice();
country.add("INDIA");
country.add("CHINA");
country.add("JAPAN");
country.add("NEPAL");
country.add("ENGLAND");
country.add("KENYA");
country.add("AMERICA");
add(country);
country.addItemListener(this);
}
public void itemStateChanged(ItemEvent e)
{
}
public static void main(String args[])
{
ListDemo frame = new ListDemo("AWT ListDemo ");
frame.setSize(200,200);
frame.setBackground(Color.pink);
frame.setVisible(true);
}
}
public class JList
extends JComponent
implements Scrollable, Accessible
Constructor | Description |
---|---|
JList() | Constructs a JList with an empty, read-only, model. |
JList(E[] ListData) | Constructor creates a JList that’s displays element in the specified arrays. |
JList(ListModel<E> dataModel) | Constructs a JList that display elements from the specified, non-null model. |
JList(Vector <? extends E> listDate) | Used to construct a JList that displays the elements in the specified Vector. |