java.lang.Object | +--java.awt.Component | +--java.awt.List
Unsafe:
(package private) Vector
items
(package private) boolean
multipleMode
multipleMode is a variable that will
be set to true if a list component is to be set to
multiple selection mode, that is where the user can
select more than one item in a list at one time.
(package private) int
rows
List Component.
(package private) int[]
selected
selected is an array that will contain
the indices of items that have been selected.
(package private) int
visibleIndex
accessibleContext, actionListenerK, adjustmentListenerK, appContext, background, BOTTOM_ALIGNMENT, bufferStrategy, CENTER_ALIGNMENT, componentListener, componentListenerK, componentOrientation, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, focusTraversalKeys, font, foreground, graphicsConfig, height, hierarchyBoundsListener, hierarchyBoundsListenerK, hierarchyListener, hierarchyListenerK, ignoreRepaint, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, metrics, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, mouseWheelListener, mouseWheelListenerK, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, RIGHT_ALIGNMENT, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowClosingException, windowFocusListenerK, windowListenerK, windowStateListenerK, x, y
List()
List(int rows)
List(int rows,
boolean multipleMode)
void
add(String item,
int index)
void
addActionListener(ActionListener l)
void
addItemListener(ItemListener l)
boolean
allowsMultipleSelections()
isMultipleMode().
void
delItems(int start,
int end)
AccessibleContext
getAccessibleContext()
AccessibleContext associated with this
List.
ActionListener[]
getActionListeners()
ItemListener[]
getItemListeners()
EventListener[]
getListeners(Class listenerType)
FooListeners
upon this List.
Dimension
getMinimumSize(int rows)
Dimension
getPreferredSize(int rows)
Object[]
getSelectedObjects()
int
getVisibleIndex()
makeVisible.
boolean
isIndexSelected(int index)
boolean
isSelected(int index)
isIndexSelected(int).
Dimension
minimumSize()
getMinimumSize().
Dimension
minimumSize(int rows)
getMinimumSize(int).
protected String
paramString()
Dimension
preferredSize()
getPreferredSize().
Dimension
preferredSize(int rows)
getPreferredSize(int).
protected void
processActionEvent(ActionEvent e)
ActionListener objects.
protected void
processItemEvent(ItemEvent e)
ItemListener objects.
private void
readObject(ObjectInputStream s)
ObjectInputStream and if it
isn't null adds a listener to receive
both item events and action events (as specified
by the key stored in the stream) fired by the
List.
void
remove(int position)
void
removeActionListener(ActionListener l)
void
removeItemListener(ItemListener l)
void
replaceItem(String newValue,
int index)
void
setMultipleMode(boolean b)
void
setMultipleSelections(boolean b)
setMultipleMode(boolean).
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, adjustListeningChildrenOnParent, applyComponentOrientation, areFocusTraversalKeysSet, areInputMethodsEnabled, autoProcessMouseWheel, autoTransferFocus, bounds, checkGD, checkImage, checkImage, checkWindowClosingException, clearCurrentFocusCycleRootOnHide, clearMostRecentFocusOwnerOnHide, coalesceEvents, contains, contains, containsFocus, countHierarchyMembers, createBufferStrategy, createBufferStrategy, createChildHierarchyEvents, createHierarchyEvents, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, dispatchEventImpl, dispatchMouseWheelToAncestor, doLayout, enable, enable, enableEvents, enableInputMethods, eventTypeEnabled, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleIndexInParent, getAccessibleStateSet, getAlignmentX, getAlignmentY, getBackBuffer, getBackground, getBounds, getBounds, getBufferStrategy, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys_NoIDCheck, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen_NoTreeLock, getLocationOnScreen, getMaximumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getToolkitImpl, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, initializeFocusTraversalKeys, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFocusTraversableOverridden, isFontSet, isForegroundSet, isLightweight, isOpaque, isRecursivelyVisible, isShowing, isValid, isVisible, iterate, keyDown, keyUp, layout, lightweightPaint, lightweightPrint, list, list, list, list, list, locate, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, nextFocusHelper, numListening, paint, paintAll, paintHeavyweightComponents, postEvent, postsOldMouseEvents, prepareImage, prepareImage, print, printAll, printHeavyweightComponents, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusHelper, requestFocusInWindow, requestFocusInWindow, resetGC, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys_NoIDCheck, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setGCFromPeer, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocus, transferFocusBackward, transferFocusUpCycle, update, updateCursorImmediately, validate
Vector items
addItem(),
getItem()int rows
List Component. It is specified only once, and
that is when the list component is actually
created. It will never change.
getRows()boolean multipleMode
multipleMode is a variable that will
be set to true if a list component is to be set to
multiple selection mode, that is where the user can
select more than one item in a list at one time.
multipleMode will be set to false if the
list component is set to single selection, that is where
the user can only select one item on the list at any
one time.
isMultipleMode(),
setMultipleMode()int[] selected
selected is an array that will contain
the indices of items that have been selected.
getSelectedIndexes(),
getSelectedIndex()int visibleIndex
makeVisible()transient ActionListener actionListener
transient ItemListener itemListener
private static final String base
private static int nameCounter
private static final long serialVersionUID
static final int DEFAULT_VISIBLE_ROWS
private int listSerializedDataVersion
List component's
Serialized Data Version.
public List() throws HeadlessException
List(0, false). Also note that the number of visible
lines in the list cannot be changed after it has been created.
java.awt.GraphicsEnvironment#isHeadlesspublic List(int rows) throws HeadlessException
List(rows, false). Also note that the number
of visible rows in the list cannot be changed after it has
been created.
rows - the number of items to show.java.awt.GraphicsEnvironment#isHeadlesspublic List(int rows, boolean multipleMode) throws HeadlessException
multipleMode is
true, then the user can select multiple items from
the list. If it is false, only one item at a time
can be selected.
rows - the number of items to show.multipleMode - if true,
then multiple selections are allowed;
otherwise, only one item can be selected at a time.java.awt.GraphicsEnvironment#isHeadlessString constructComponentName()
getName when the name is null.
constructComponentName in class Componentpublic void addNotify()
public void removeNotify()
removeNotify in class Componentpublic int getItemCount()
getItem(int)public int countItems()
getItemCount().
public String getItem(int index)
index - the position of the item
getItemCount()final String getItemImpl(int index)
public String[] getItems()
select(int),
deselect(int),
isIndexSelected(int)public void add(String item)
item - the item to be addedpublic void addItem(String item)
add(String).
public void add(String item, int index)
item - the item to be added;
if this parameter is null then the item is
treated as an empty string, ""index - the position at which to add the itempublic void addItem(String item, int index)
add(String, int).
public void replaceItem(String newValue, int index)
newValue - a new string to replace an existing itemindex - the position of the item to replacepublic void removeAll()
remove(java.lang.String),
delItems(int, int)public void clear()
removeAll().
public void remove(String item)
item - the item to remove from the listpublic void remove(int position)
position - the index of the item to deleteadd(String, int)public void delItem(int position)
remove(String)
and remove(int).
public int getSelectedIndex()
-1 if no item is selected,
or if more that one item is selectedselect(int),
deselect(int),
isIndexSelected(int)public int[] getSelectedIndexes()
select(int),
deselect(int),
isIndexSelected(int)public String getSelectedItem()
null if no item is selectedselect(int),
deselect(int),
isIndexSelected(int)public String[] getSelectedItems()
select(int),
deselect(int),
isIndexSelected(int)public Object[] getSelectedObjects()
getSelectedObjects in interface ItemSelectableItemSelectablepublic void select(int index)
Note that this method should be primarily used to
initially select an item in this component.
Programmatically calling this method will not trigger
an ItemEvent. The only way to trigger an
ItemEvent is by user interaction.
index - the position of the item to selectgetSelectedItem(),
deselect(int),
isIndexSelected(int)public void deselect(int index)
If the item at the specified index is not selected, or if the index is out of range, then the operation is ignored.
index - the position of the item to deselectselect(int),
getSelectedItem(),
isIndexSelected(int)public boolean isIndexSelected(int index)
index - the item to be checked
true if the specified item has been
selected; false otherwiseselect(int),
deselect(int)public boolean isSelected(int index)
isIndexSelected(int).
public int getRows()
List has been created, this number
will never change.
public boolean isMultipleMode()
true if this list allows multiple
selections; otherwise, falsesetMultipleMode(boolean)public boolean allowsMultipleSelections()
isMultipleMode().
public void setMultipleMode(boolean b)
b - if true then multiple selections
are allowed; otherwise, only one item from
the list can be selected at onceisMultipleMode()public void setMultipleSelections(boolean b)
setMultipleMode(boolean).
public int getVisibleIndex()
makeVisible.
makeVisible(int)public void makeVisible(int index)
index - the position of the itemgetVisibleIndex()public Dimension getPreferredSize(int rows)
rows - number of rows in the list
java.awt.Component#getPreferredSizepublic Dimension preferredSize(int rows)
getPreferredSize(int).
public Dimension getPreferredSize()
getPreferredSize in class Componentjava.awt.Component#getPreferredSizepublic Dimension preferredSize()
getPreferredSize().
preferredSize in class Componentpublic Dimension getMinimumSize(int rows)
rows - number of rows in the list
java.awt.Component#getMinimumSizepublic Dimension minimumSize(int rows)
getMinimumSize(int).
public Dimension getMinimumSize()
getMinimumSize in class Componentjava.awt.Component#getMinimumSize()public Dimension minimumSize()
getMinimumSize().
minimumSize in class Componentpublic void addItemListener(ItemListener l)
select or deselect.
If listener l is null,
no exception is thrown and no action is performed.
addItemListener in interface ItemSelectablel - the item listenerremoveItemListener(java.awt.event.ItemListener),
getItemListeners(),
select(int),
deselect(int),
java.awt.event.ItemEvent,
java.awt.event.ItemListenerpublic void removeItemListener(ItemListener l)
l is null,
no exception is thrown and no action is performed.
removeItemListener in interface ItemSelectablel - the item listeneraddItemListener(java.awt.event.ItemListener),
getItemListeners(),
java.awt.event.ItemEvent,
java.awt.event.ItemListenerpublic ItemListener[] getItemListeners()
ItemListeners
or an empty array if no item
listeners are currently registeredaddItemListener(java.awt.event.ItemListener),
removeItemListener(java.awt.event.ItemListener),
java.awt.event.ItemEvent,
java.awt.event.ItemListenerpublic void addActionListener(ActionListener l)
l is null,
no exception is thrown and no action is performed.
l - the action listenerremoveActionListener(java.awt.event.ActionListener),
getActionListeners(),
java.awt.event.ActionEvent,
java.awt.event.ActionListenerpublic void removeActionListener(ActionListener l)
l is null,
no exception is thrown and no action is performed.
l - the action listeneraddActionListener(java.awt.event.ActionListener),
getActionListeners(),
java.awt.event.ActionEvent,
java.awt.event.ActionListenerpublic ActionListener[] getActionListeners()
ActionListeners
or an empty array if no action
listeners are currently registeredaddActionListener(java.awt.event.ActionListener),
removeActionListener(java.awt.event.ActionListener),
java.awt.event.ActionEvent,
java.awt.event.ActionListenerpublic EventListener[] getListeners(Class listenerType)
FooListeners
upon this List.
FooListeners are registered using the
addFooListener method.
You can specify the listenerType argument
with a class literal, such as
FooListener.class.
For example, you can query a
List l
for its item listeners with the following code:
ItemListener[] ils = (ItemListener[])(l.getListeners(ItemListener.class));If no such listeners exist, this method returns an empty array.
getListeners in class ComponentlistenerType - the type of listeners requested; this parameter
should specify an interface that descends from
java.util.EventListener
FooListeners on this list,
or an empty array if no such
listeners have been addedgetItemListeners()boolean eventEnabled(AWTEvent e)
eventEnabled in class Componentprotected void processEvent(AWTEvent e)
ItemEvent, it invokes the
processItemEvent method. Else, if the
event is an instance of ActionEvent,
it invokes processActionEvent.
If the event is not an item event or an action event,
it invokes processEvent on the superclass.
Note that if the event parameter is null
the behavior is unspecified and may result in an
exception.
processEvent in class Componente - the eventjava.awt.event.ActionEvent,
java.awt.event.ItemEvent,
processActionEvent(java.awt.event.ActionEvent),
processItemEvent(java.awt.event.ItemEvent)protected void processItemEvent(ItemEvent e)
ItemListener objects.
This method is not called unless item events are enabled for this component. Item events are enabled when one of the following occurs:
ItemListener object is registered
via addItemListener.
enableEvents.
Note that if the event parameter is null
the behavior is unspecified and may result in an
exception.
e - the item eventjava.awt.event.ItemEvent,
java.awt.event.ItemListener,
addItemListener(java.awt.event.ItemListener),
java.awt.Component#enableEventsprotected void processActionEvent(ActionEvent e)
ActionListener objects.
This method is not called unless action events are enabled for this component. Action events are enabled when one of the following occurs:
ActionListener object is registered
via addActionListener.
enableEvents.
Note that if the event parameter is null
the behavior is unspecified and may result in an
exception.
e - the action eventjava.awt.event.ActionEvent,
java.awt.event.ActionListener,
addActionListener(java.awt.event.ActionListener),
java.awt.Component#enableEventsprotected String paramString()
paramString in class Componentpublic void delItems(int start, int end)
private void writeObject(ObjectOutputStream s) throws IOException
ItemListeners
and ActionListeners as optional data.
The non-serializable listeners are detected and
no attempt is made to serialize them.
s - the ObjectOutputStream to write
IOExceptionAWTEventMulticaster.save(ObjectOutputStream, String, EventListener),
java.awt.Component.itemListenerK,
java.awt.Component.actionListenerK,
readObject(java.io.ObjectInputStream)private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException, HeadlessException
ObjectInputStream and if it
isn't null adds a listener to receive
both item events and action events (as specified
by the key stored in the stream) fired by the
List.
Unrecognized keys or values will be ignored.
s - the ObjectInputStream to write
ClassNotFoundException
IOException
HeadlessExceptionremoveActionListener(),
addActionListener(),
java.awt.GraphicsEnvironment#isHeadless,
writeObject(java.io.ObjectOutputStream)public AccessibleContext getAccessibleContext()
AccessibleContext associated with this
List. For lists, the AccessibleContext
takes the form of an AccessibleAWTList.
A new AccessibleAWTList instance is created, if necessary.
getAccessibleContext in interface AccessiblegetAccessibleContext in class ComponentAccessibleAWTList that serves as the
AccessibleContext of this List