List

Name

List

[Graphic: Figure from the text]

Description

The List is a Component that provides a scrollable list of choices to select from. A List can be in one of two modes: single selection mode, in which only one item may be selected at a time; and multiple selection mode, in which several items may be selected at one time. A list does not necessarily display all of the choices at one time; one of the constructors lets you specify the number of choices to display simultaneously. Although the changes in 1.1 are extensive, almost all of them can be boiled down to (1) using the 1.1 event model, and (2) standardizing method names (e.g. set/get pairs).

Class Definition

public class java.awt.List extends java.awt.Component implements java.awt.ItemSelectable {
 // Constructors public List();
public List (int rows); public List (int rows, boolean multipleSelections); // Instance Methods public void add (String item); public synchronized void add (String item, int index); public void addActionListener (ActionListener l); public void addItem (String item);
public synchronized void addItem (String item, int index); (Deprecated) public void addItemListener (ItemListener l); public void addNotify();
public boolean allowsMultipleSelections(); (Deprecated) public synchronized void clear(); (Deprecated) public int countItems(); (Deprecated) public synchronized void delItem (int position);
public synchronized void delItems (int start, int end); (Deprecated) public synchronized void deselect (int index);
public String getItem (int index);
public int getItemCount(); public synchronized String[] getItems(); public Dimension getMinimumSize(); public Dimension getMinimumSize (int rows); public Dimension getPreferredSize(); public Dimension getPreferredSize (int rows); public int getRows();
public synchronized int getSelectedIndex();
public synchronized int[] getSelectedIndexes();
public synchronized String getSelectedItem();
public synchronized String[] getSelectedItems();
public Object[] getSelectedObjects(); public int getVisibleIndex();
public boolean isIndexSelected(int index); public boolean isMultipleMode(); public boolean isSelected (int index); (Deprecated) public synchronized void makeVisible (int index);
public Dimension minimumSize(); (Deprecated) public Dimension minimumSize (int rows); (Deprecated) public Dimension preferredSize(); (Deprecated) public Dimension preferredSize (int rows); (Deprecated) public synchronized void remove (int position); public synchronized void remove (String item); public void removeActionListener (ActionListener l); public synchronized void removeAll(); public void removeItemListener (ItemListener l); public void removeNotify();
public synchronized void replaceItem (String newItem, int index);
public synchronized void select (int position);
public synchronized void setMultipleMode (boolean b); public synchronized void setMultipleSelections (boolean value); (Deprecated) // Protected Instance Methods protected String paramString(); protected void processActionEvent (ActionEvent e); protected void processEvent (AWTEvent e); protected void processItemEvent (ItemEvent e);
}

Constructors

List

public List()

public List (int rows)

public List (int rows, boolean multipleSelections)

Instance Methods

add

public void add (String item)

public synchronized void add (String item, int index)

addActionListener

public void addActionListener (ActionListener l)

addItem

public void addItem (String item)

public synchronized void addItem (String item, int index) (Deprecated)

addItemListener

public void addItemListener (ItemListener l)

addNotify

public void addNotify()

allowsMultipleSelections

public boolean allowsMultipleSelections() (Deprecated)

clear

public synchronized void clear() (Deprecated)

countItems

public int countItems() (Deprecated)

delItem

public synchronized void delItem (int position)

delItems

public synchronized void delItems (int start, int end) (Deprecated)

deselect

public synchronized void deselect (int index)

getItem

public String getItem (int index)

getItemCount

public int getItemCount()

getItems

public String[] getItems()

getMinimumSize

public Dimension getMinimumSize()

public Dimension getMinimumSize (int rows)

getPreferredSize

public Dimension getPreferredSize()

public Dimension getPreferredSize (int rows)

getRows

public int getRows()

getSelectedIndex

public synchronized int getSelectedIndex()

getSelectedIndexes

public synchronized int[] getSelectedIndexes()

getSelectedItem

public synchronized String getSelectedItem()

getSelectedItems

public synchronized String[] getSelectedItems()

getSelectedObjects

public Object[] getSelectedObjects()

getVisibleIndex

public int getVisibleIndex()

isIndexSelected

public boolean isIndexSelected (int index)

isMultipleMode

public boolean isMultipleMode()

isSelected

public boolean isSelected (int index) (Deprecated)

makeVisible

public synchronized void makeVisible (int index)

minimumSize

public Dimension minimumSize() (Deprecated)

public Dimension minimumSize (int rows) (Deprecated)

preferredSize

public Dimension preferredSize() (Deprecated)

public Dimension preferredSize (int rows) (Deprecated)

remove

public synchronized void remove (int position)

public synchronized void remove (String item)

removeActionListener

public void removeActionListener (ActionListener l)

removeAll

public synchronized removeAll()

removeItemListener

public void removeItemListener (ItemListener l)

removeNotify

public void removeNotify()

replaceItem

public synchronized void replaceItem (String newItem, int index)

select

public synchronized void select (int position)

setMultipleMode

public synchronized void setMultipleMode (boolean b)

setMultipleSelections

public synchronized void setMultipleSelections (boolean value) (Deprecated)

Protected Instance Methods

paramString

protected String paramString()

processActionEvent

protected void processActionEvent (ActionEvent e)

processEvent

protected void processEvent (AWTEvent e)

processItemEvent

protected void processItemEvent(ItemEvent e)

See Also

Component, Dimension, ItemSelectable, String