|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.List
public class List
Class that implements a listbox widget
Nested Class Summary | |
---|---|
protected class |
List.AccessibleAWTList
|
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary |
---|
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
List()
Initializes a new instance of List with no visible lines
and multi-select disabled. |
|
List(int rows)
Initializes a new instance of List with the specified
number of visible lines and multi-select disabled. |
|
List(int rows,
boolean multipleMode)
Initializes a new instance of List with the specified
number of lines and the specified multi-select setting. |
Method Summary | ||
---|---|---|
void |
add(String item)
This method adds the specified item to the end of the list. |
|
void |
add(String item,
int index)
Adds the specified item to the specified location in the list. |
|
void |
addActionListener(ActionListener listener)
Adds the specified ActionListener to the list of
registered listeners for this object. |
|
void |
addItem(String item)
Deprecated. Use add() instead. |
|
void |
addItem(String item,
int index)
Deprecated. Use add() instead. |
|
void |
addItemListener(ItemListener listener)
Adds the specified ItemListener to the list of
registered listeners for this object. |
|
void |
addNotify()
Notifies this object to create its native peer. |
|
boolean |
allowsMultipleSelections()
Deprecated. This method is deprecated in favor of isMultipleMode() . |
|
void |
clear()
Deprecated. This method is deprecated in favor of removeAll() . |
|
int |
countItems()
Deprecated. This method is deprecated in favor of getItemCount() |
|
void |
delItem(int index)
Deprecated. |
|
void |
delItems(int start,
int end)
Deprecated. This method is deprecated for some unknown reason. |
|
void |
deselect(int index)
Makes the item at the specified index not selected. |
|
AccessibleContext |
getAccessibleContext()
Gets the AccessibleContext associated with this List . |
|
ActionListener[] |
getActionListeners()
Returns all action listeners registered to this object. |
|
String |
getItem(int index)
Returns the item at the specified index. |
|
int |
getItemCount()
Returns the number of items in this list. |
|
ItemListener[] |
getItemListeners()
Returns all action listeners registered to this object. |
|
String[] |
getItems()
Returns the complete list of items. |
|
|
getListeners(Class<T> listenerType)
Returns an array of all the objects currently registered as FooListeners upon this List . |
|
Dimension |
getMinimumSize()
Returns the minimum size of this component. |
|
Dimension |
getMinimumSize(int rows)
Returns the minimum size of this component assuming it had the specified number of rows. |
|
Dimension |
getPreferredSize()
Returns the preferred size of this component. |
|
Dimension |
getPreferredSize(int rows)
Returns the preferred size of this component assuming it had the specified number of rows. |
|
int |
getRows()
Returns the number of visible rows in the list. |
|
int |
getSelectedIndex()
Returns the index of the currently selected item |
|
int[] |
getSelectedIndexes()
Returns an array containing the indexes of the rows that are currently selected. |
|
String |
getSelectedItem()
Returns the item that is currently selected, or null if there
is no item selected. |
|
String[] |
getSelectedItems()
Returns the list of items that are currently selected in this list. |
|
Object[] |
getSelectedObjects()
Returns the list of items that are currently selected in this list as an array of type Object[] instead of String[] . |
|
int |
getVisibleIndex()
Returns the index of the last item that was made visible via the makeVisible() method. |
|
boolean |
isIndexSelected(int index)
Tests whether or not the specified index is selected. |
|
boolean |
isMultipleMode()
Tests whether or not multi-select mode is enabled. |
|
boolean |
isSelected(int index)
Deprecated. This method is deprecated in favor of isIndexSelected(int) . |
|
void |
makeVisible(int index)
This method ensures that the item at the specified index is visible. |
|
Dimension |
minimumSize()
Deprecated. This method is deprecated in favor of getMinimumSize . |
|
Dimension |
minimumSize(int rows)
Deprecated. This method is deprecated in favor of getMinimumSize(int) > |
|
protected String |
paramString()
Returns a debugging string for this object. |
|
Dimension |
preferredSize()
Deprecated. This method is deprecated in favor of getPreferredSize . |
|
Dimension |
preferredSize(int rows)
Deprecated. This method is deprecated in favor of getPreferredSize(int) > |
|
protected void |
processActionEvent(ActionEvent event)
This method processes the specified event by dispatching it to any registered listeners. |
|
protected void |
processEvent(AWTEvent event)
Processes the specified event for this object. |
|
protected void |
processItemEvent(ItemEvent event)
This method processes the specified event by dispatching it to any registered listeners. |
|
void |
remove(int index)
Deletes the item at the specified index. |
|
void |
remove(String item)
Deletes the first occurrence of the specified item from the list. |
|
void |
removeActionListener(ActionListener listener)
Removes the specified ActionListener from the list of
registers listeners for this object. |
|
void |
removeAll()
Deletes all of the items from the list. |
|
void |
removeItemListener(ItemListener listener)
Removes the specified ItemListener from the list of
registers listeners for this object. |
|
void |
removeNotify()
Notifies this object to destroy its native peer. |
|
void |
replaceItem(String item,
int index)
Replaces the item at the specified index with the specified item. |
|
void |
select(int index)
Makes the item at the specified index selected. |
|
void |
setMultipleMode(boolean multipleMode)
This method enables or disables multiple selection mode for this list. |
|
void |
setMultipleSelections(boolean multipleMode)
Deprecated. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public List()
List
with no visible lines
and multi-select disabled.
HeadlessException
- If GraphicsEnvironment.isHeadless() is true.public List(int rows)
List
with the specified
number of visible lines and multi-select disabled.
rows
- The number of visible rows in the list.
HeadlessException
- If GraphicsEnvironment.isHeadless() is true.public List(int rows, boolean multipleMode)
List
with the specified
number of lines and the specified multi-select setting.
rows
- The number of visible rows in the list.multipleMode
- true
if multiple lines can be selected
simultaneously, false
otherwise.
HeadlessException
- If GraphicsEnvironment.isHeadless() is true.Method Detail |
---|
public int getItemCount()
public int countItems()
getItemCount()
public String[] getItems()
public String getItem(int index)
index
- The index of the item to retrieve.
IndexOutOfBoundsException
- If the index value is not valid.public int getRows()
public boolean isMultipleMode()
true
if multi-select mode is enabled,
false
otherwise.public boolean allowsMultipleSelections()
isMultipleMode()
.
true
if multi-select mode is enabled,
false
otherwise.public void setMultipleMode(boolean multipleMode)
multipleMode
- true
to enable multiple mode,
false
otherwise.public void setMultipleSelections(boolean multipleMode)
multipleMode
- true
to enable multiple mode,
false
otherwise.public Dimension getMinimumSize()
getMinimumSize
in class Component
Component.getPreferredSize()
,
Component.setMinimumSize(Dimension)
,
LayoutManager
public Dimension minimumSize()
getMinimumSize
.
minimumSize
in class Component
public Dimension getMinimumSize(int rows)
rows
- The number of rows to size for.
public Dimension minimumSize(int rows)
getMinimumSize(int)
>
rows
- The number of rows to size for.
public Dimension getPreferredSize()
getPreferredSize
in class Component
Component.getMinimumSize()
,
Component.setPreferredSize(Dimension)
,
LayoutManager
public Dimension preferredSize()
getPreferredSize
.
preferredSize
in class Component
public Dimension getPreferredSize(int rows)
rows
- The number of rows to size for.
public Dimension preferredSize(int rows)
getPreferredSize(int)
>
rows
- The number of rows to size for.
public void add(String item)
item
- The item to add to the list.public void addItem(String item)
item
- The item to add to the list.public void add(String item, int index)
item
- The item to add to the list.index
- The location in the list to add the item, or -1 to add
to the end.public void addItem(String item, int index)
item
- The item to add to the list.index
- The location in the list to add the item, or -1 to add
to the end.public void delItem(int index) throws IllegalArgumentException
index
- The index of the item to delete.
IllegalArgumentException
- If the index is not validpublic void remove(int index) throws IllegalArgumentException
index
- The index of the item to delete.
IllegalArgumentException
- If the index is not validpublic void delItems(int start, int end) throws IllegalArgumentException
start
- The beginning index of the range to delete.end
- The ending index of the range to delete.
IllegalArgumentException
- If the indexes are not validpublic void remove(String item) throws IllegalArgumentException
item
- The item to delete.
IllegalArgumentException
- If the specified item does not exist.public void removeAll()
public void clear()
removeAll()
.
public void replaceItem(String item, int index) throws ArrayIndexOutOfBoundsException
item
- The new item value.index
- The index of the item to replace.
ArrayIndexOutOfBoundsException
- If the index is not valid.public int getSelectedIndex()
public int[] getSelectedIndexes()
public String getSelectedItem()
null
if there
is no item selected. FIXME: What happens if multiple items selected?
null
if there is no
selected item.public String[] getSelectedItems()
public Object[] getSelectedObjects()
Object[]
instead of String[]
.
getSelectedObjects
in interface ItemSelectable
public boolean isIndexSelected(int index)
index
- The index to test.
true
if the index is selected, false
otherwise.public boolean isSelected(int index)
isIndexSelected(int)
.
index
- The index to test.
true
if the index is selected, false
otherwise.public void makeVisible(int index) throws IllegalArgumentException
index
- The index of the item to be made visible.
IllegalArgumentException
public int getVisibleIndex()
makeVisible()
method.
makeVisible()
method.public void select(int index)
index
- The index of the item to select.public void deselect(int index)
index
- The index of the item to unselect.public void addNotify()
addNotify
in class Component
Component.isDisplayable()
,
Component.removeNotify()
public void removeNotify()
removeNotify
in class Component
Component.isDisplayable()
,
Component.addNotify()
public void addActionListener(ActionListener listener)
ActionListener
to the list of
registered listeners for this object.
listener
- The listener to add.public void removeActionListener(ActionListener listener)
ActionListener
from the list of
registers listeners for this object.
listener
- The listener to remove.public void addItemListener(ItemListener listener)
ItemListener
to the list of
registered listeners for this object.
addItemListener
in interface ItemSelectable
listener
- The listener to add.public void removeItemListener(ItemListener listener)
ItemListener
from the list of
registers listeners for this object.
removeItemListener
in interface ItemSelectable
listener
- The listener to remove.protected void processEvent(AWTEvent event)
ActionEvent
then the
processActionEvent()
method is called. Similarly, if the
even is an instance of ItemEvent
then the
processItemEvent()
method is called. Otherwise the
superclass method is called to process this event.
processEvent
in class Component
event
- The event to process.Component.processComponentEvent(ComponentEvent)
,
Component.processFocusEvent(FocusEvent)
,
Component.processKeyEvent(KeyEvent)
,
Component.processMouseEvent(MouseEvent)
,
Component.processMouseMotionEvent(MouseEvent)
,
Component.processInputMethodEvent(InputMethodEvent)
,
Component.processHierarchyEvent(HierarchyEvent)
,
Component.processMouseWheelEvent(MouseWheelEvent)
protected void processActionEvent(ActionEvent event)
enableEvents()
method.
event
- The event to process.protected void processItemEvent(ItemEvent event)
enableEvents()
method.
event
- The event to process.protected String paramString()
paramString
in class Component
public <T extends EventListener> T[] getListeners(Class<T> listenerType)
List
. FooListeners are registered using the
addFooListener method.
getListeners
in class Component
listenerType
- the class of listeners to filter (null
not permitted).
ClassCastException
- If listenerType doesn't specify a class or
interface that implements java.util.EventListener.Component.getComponentListeners()
,
Component.getFocusListeners()
,
Component.getHierarchyListeners()
,
Component.getHierarchyBoundsListeners()
,
Component.getKeyListeners()
,
Component.getMouseListeners()
,
Component.getMouseMotionListeners()
,
Component.getMouseWheelListeners()
,
Component.getInputMethodListeners()
,
Component.getPropertyChangeListeners()
public ActionListener[] getActionListeners()
public ItemListener[] getItemListeners()
public AccessibleContext getAccessibleContext()
List
.
The context is created, if necessary.
getAccessibleContext
in interface Accessible
getAccessibleContext
in class Component
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |