Class ListView
All Packages Class Hierarchy This Package Previous Next Index
Class ListView
public class netscape.application.ListView
extends netscape.application.View
{
/* Constructors
*/
public ListView();
public ListView(Rect);
public ListView(int, int, int, int);
/* Methods
*/
public ListItem addItem();
public ListItem addItem(ListItem);
public boolean allowsEmptySelection();
public boolean allowsMultipleSelection();
public Color backgroundColor();
public String command();
public int count();
public void decode(Decoder);
public void describeClassInfo(ClassInfo);
public void deselectItem(ListItem);
public String doubleCommand();
public void drawItemAt(int);
public void drawView(Graphics);
public void drawViewBackground(Graphics, int, int, int, int);
public void encode(Encoder);
public int indexOfItem(ListItem);
public ListItem insertItemAt(ListItem, int);
public ListItem insertItemAt(int);
public boolean isEnabled();
public boolean isTransparent();
public ListItem itemAt(int);
public ListItem itemForPoint(int, int);
public int minItemHeight();
public int minItemWidth();
public Size minSize();
public boolean mouseDown(MouseEvent);
public void mouseDragged(MouseEvent);
public void mouseUp(MouseEvent);
public boolean multipleItemsSelected();
public ListItem prototypeItem();
public Rect rectForItem(ListItem);
public Rect rectForItemAt(int);
public void removeAllItems();
public void removeItem(ListItem);
public void removeItemAt(int);
public int rowHeight();
public void scrollItemAtToVisible(int);
public void scrollItemToVisible(ListItem);
public void selectItem(ListItem);
public void selectItemAt(int);
public void selectOnly(ListItem);
public int selectedIndex();
public ListItem selectedItem();
public Vector selectedItems();
public void sendCommand();
public void sendDoubleCommand();
public void setAllowsEmptySelection(boolean);
public void setAllowsMultipleSelection(boolean);
public void setBackgroundColor(Color);
public void setCommand(String);
public void setDoubleCommand(String);
public void setEnabled(boolean);
public void setPrototypeItem(ListItem);
public void setRowHeight(int);
public void setTarget(Target);
public void setTracksMouseOutsideBounds(boolean);
public void setTransparent(boolean);
public Target target();
public boolean tracksMouseOutsideBounds();
public boolean wantsAutoscrollEvents();
}
View subclass that maintains a vertical column of ListItems. ListItems can
be selected and deselected programmatically or via the mouse. The
ListView can also send a command to a Target when the user single- or
double-clicks on a ListItem. ListViews are often placed in ScrollViews to
accommodate larger amounts of data.
Note that the ListView does not resize itself automatically to fit it's
ListItems. If you create a ListView of a particular size and add too many
ListItems, the ListItems that do not fit within the bounds of the ListView
will not appear displayed. After adding or removing ListItems, you should
call sizeToMinSize() to force the ListView to adjust to its new
contents.
- See Also:
- ListItem, ScrollView, Target
Constructors
ListView
public ListView()
- Constructs an empty ListView.
ListView
public ListView(Rect rect)
- Constructs a ListView with bounds rect.
ListView
public ListView(int x,
int y,
int width,
int height)
- Constructs an empty ListView with the given bounds.
Methods
setPrototypeItem
public void setPrototypeItem(ListItem item)
- Sets the ListView's "prototype" ListItem. ListView adds additional
rows by cloning its prototype ListItem. Typical usage consists of
configuring the prototype ListItem and then modifying only the
unique attributes on a per-row basis. By default, the prototype
ListItem is just a generic ListItem instance.
- See Also:
- addItem, insertItemAt
prototypeItem
public ListItem prototypeItem()
- Returns the prototype ListItem.
- See Also:
- setPrototypeItem
setBackgroundColor
public void setBackgroundColor(Color color)
- Sets the color drawn behind transparent ListItems, and any area in
the ListView not covered by ListItems.
backgroundColor
public Color backgroundColor()
- Returns the background color.
- See Also:
- setBackgroundColor
setTransparent
public void setTransparent(boolean flag)
- Sets the ListView to be transparent or opaque.
isTransparent
public boolean isTransparent()
- Overridden to return true if the ListView is transparent.
- Overrides:
- isTransparent in class View
- See Also:
- setTransparent
wantsAutoscrollEvents
public boolean wantsAutoscrollEvents()
- Overridden to return true (ListViews can be autoscrolled).
- Overrides:
- wantsAutoscrollEvents in class View
setAllowsMultipleSelection
public void setAllowsMultipleSelection(boolean flag)
- Sets whether multiple ListItems can be selected simultaneously.
allowsMultipleSelection
public boolean allowsMultipleSelection()
- Returns true if multiple ListItems can be selected
simultaneously.
- See Also:
- setAllowsMultipleSelection
setAllowsEmptySelection
public void setAllowsEmptySelection(boolean flag)
- Sets whether the ListView allows a selection of zero ListItems.
allowsEmptySelection
public boolean allowsEmptySelection()
- Returns true if the List allows a selection of zero ListItems.
- See Also:
- setAllowsEmptySelection
setTracksMouseOutsideBounds
public void setTracksMouseOutsideBounds(boolean flag)
- Sets whether the ListView tracks the mouse outside its bounds. By
default, ListViews track the mouse outside of their bounds, which
means that if the user drags the mouse outside of the ListView's
bounds, the ListView will continue to modify the current selection.
Certain ListViews, like the ones in Popups, do not track the mouse
outside of their bounds (when the user moves the mouse outside of the
ListView's bounds, the current selection will not change).
tracksMouseOutsideBounds
public boolean tracksMouseOutsideBounds()
- Returns true if the ListView tracks the mouse outside its
bounds.
- See Also:
- setTracksMouseOutsideBounds
setEnabled
public void setEnabled(boolean flag)
- Enables or disables the ListView and marks it dirty.
isEnabled
public boolean isEnabled()
- Returns true if the ListView is enabled.
- See Also:
- setEnabled
setRowHeight
public void setRowHeight(int height)
- Sets the height of each row in the ListView. Each ListView rows has the
same height. If height is 0, sets the height to
minItemHeight().
- See Also:
- minItemHeight
rowHeight
public int rowHeight()
- Returns the ListView's row height.
- See Also:
- setRowHeight
minItemHeight
public int minItemHeight()
- Returns the largest minHeight() of all of the ListView's
ListItems.
minItemWidth
public int minItemWidth()
- Returns the largest minWidth() of all of the ListView's
ListItems.
minSize
public Size minSize()
- Returns a Size consisting of the current width and the minimum
height necessary to accommodate all the rows.
- Overrides:
- minSize in class View
itemForPoint
public ListItem itemForPoint(int x,
int y)
- Returns the ListItem at the coordinate (x, y).
itemAt
public ListItem itemAt(int index)
- Returns the ListItem at the given row index.
indexOfItem
public int indexOfItem(ListItem item)
- Returns the row index for item.
rectForItem
public Rect rectForItem(ListItem item)
- Returns the Rect occupied by item within the ListView.
rectForItemAt
public Rect rectForItemAt(int index)
- Returns the Rect for the ListItem at the given row index.
multipleItemsSelected
public boolean multipleItemsSelected()
- Returns true if multiple ListItems are selected.
selectedIndex
public int selectedIndex()
- Returns the row of the selected ListItem. If multiple ListItems are
selected, returns the row of the first selected ListItem.
selectedItem
public ListItem selectedItem()
- Returns the selected ListItem. If multiple ListItems are selected,
returns the first one.
selectedItems
public Vector selectedItems()
- Returns a Vector of all the selected ListItems. Do not alter this
Vector.
count
public int count()
- Returns the number of ListItems in the ListView.
addItem
public ListItem addItem()
- Adds an additional row to the end of the ListView by cloning the
prototype ListItem. Returns the newly-create ListItem.
addItem
public ListItem addItem(ListItem item)
- Adds the ListItem item to the end of the ListView.
insertItemAt
public ListItem insertItemAt(ListItem item,
int index)
- Adds the ListItem item to the ListView at the given index.
insertItemAt
public ListItem insertItemAt(int index)
- Adds a row to the ListView at the given index by cloning the
prototype ListItem. Returns the newly-created ListItem.
removeItemAt
public void removeItemAt(int index)
- Removes the ListItem at the given row index.
removeItem
public void removeItem(ListItem item)
- Removes item from the ListView.
removeAllItems
public void removeAllItems()
- Empties the ListView.
selectItem
public void selectItem(ListItem item)
- Selects item within the ListView. If multiple selection is not
enabled, any currently selected ListItem is deselected. If item
is null, all of the ListView's ListItems are deselected.
selectItemAt
public void selectItemAt(int index)
- Calls selectItem() using the item at given row index
index.
selectOnly
public void selectOnly(ListItem item)
- Selects item and deselects all others.
deselectItem
public void deselectItem(ListItem item)
- Deselects item, unless empty selection is not allowed and
it is the only selected ListItem.
scrollItemAtToVisible
public void scrollItemAtToVisible(int index)
- Calls scrollRectToVisible() with the Rect for the item at
index.
- See Also:
- scrollRectToVisible
scrollItemToVisible
public void scrollItemToVisible(ListItem item)
- Calls scrollRectToVisible() with the Rect for item.
- See Also:
- scrollRectToVisible
mouseDown
public boolean mouseDown(MouseEvent event)
- Handles mouse down events within the ListView. This method selects and
deselects ListItems as the user clicks on them, and sends the
ListView's doubleCommand on a double-click. The normal command is
sent in mouseUp().
- Overrides:
- mouseDown in class View
- See Also:
- setDoubleCommand, mouseUp
mouseDragged
public void mouseDragged(MouseEvent event)
- Tracks the mouse as the user drags it, selecting and deselecting
ListItems as appropriate.
- Overrides:
- mouseDragged in class View
mouseUp
public void mouseUp(MouseEvent event)
- Calls sendCommand() on a single click mouse up.
- Overrides:
- mouseUp in class View
- See Also:
- sendCommand
drawItemAt
public void drawItemAt(int index)
- Calls draw() with the Rect for the ListItem at the given row
index.
drawViewBackground
public void drawViewBackground(Graphics g,
int x,
int y,
int width,
int height)
- Called by drawView() to draw the background for the rectangle
(x, y, width, height). You never
call this method directly, but should override it to produce custom
background drawing.
drawView
public void drawView(Graphics g)
- Draws the ListView, calling drawViewBackground() to draw each
ListItem's background.
- Overrides:
- drawView in class View
- See Also:
- drawViewBackground
setTarget
public void setTarget(Target newTarget)
- Sets the ListView's Target.
target
public Target target()
- Returns the ListView's Target.
- See Also:
- setTarget
setCommand
public void setCommand(String newCommand)
- Sets the ListView's single-click command. ListView sends this command
when the user clicks a ListItem and the ListItem does not have a
command of its own.
- See Also:
- setCommand
command
public String command()
- Returns the ListView's single-click command.
- See Also:
- setCommand
setDoubleCommand
public void setDoubleCommand(String newCommand)
- Sets the ListView's double-click command. ListView sends this command
when the user double-clicks a ListItem.
doubleCommand
public String doubleCommand()
- Returns the ListView's double-click command.
- See Also:
- setDoubleCommand
sendCommand
public void sendCommand()
- Sends the single-click command of the selected ListItem to the
ListView's target. If the selected ListItem does not have a command,
sends the ListView's single-click command.
- See Also:
- setCommand
sendDoubleCommand
public void sendDoubleCommand()
- Sends the ListView's double-click command to its Target.
- See Also:
- setDoubleCommand
describeClassInfo
public void describeClassInfo(ClassInfo info)
- Describes the ListView class' information.
- Overrides:
- describeClassInfo in class View
- See Also:
- describeClassInfo
encode
public void encode(Encoder encoder) throws CodingException
- Encodes the ListView instance.
- Overrides:
- encode in class View
- See Also:
- encode
decode
public void decode(Decoder decoder) throws CodingException
- Decodes the ListView instance.
- Overrides:
- decode in class View
- See Also:
- decode
All Packages Class Hierarchy This Package Previous Next Index