Overview | Package | Class | Tree | Deprecated | Index | Help | |||
PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--java.awt.Panel | +--gui.ObjectList
The List operations such as adding, deleting, selecting and replacing items are supported. In addition individual items may enabled or disabled (meaning they are `grayed out' and can't be selected). Items may be hidden or shown; hidden items are not visible, but keep their original position in the sequence. ObjectList can also support a hierarchical structure; children of an opened item are displayed, indented, below the parent. The necessary information is provided by subclassing and overriding the following methods:
public Object[] getChildren(Object item); public Object getParent(Object item);These return the children or parent objects respectively, out of which ObjectList will construct the necessary relationships.
The presentation of items can be also be customized. Items can be drawn graphically, and in different sizes, by overriding:
public Dimension paintItem(Graphics g, Object item);It returns the size needed to display the item. The default is to draw a string obtained from getString(item). That later may also be overridden; it's default uses the toString() method.
When an item is clicked with the mouse, the select state is toggled and a LIST_SELECT or LIST_DESELECT event is posted. A double click on an item selects the item and posts an ACTION_EVENT event. The event's arg is the item. itemBounds(item) gives the position of the item in the window, so that the position of the mouse within the item can be determined from the event's x and y coordinates, allowing different operations to be associated with different parts of the item.
To facilitate `mouse documentation', ie. highlighting the selectable item under the mouse and/or showing descriptive text in an applet's status line, the MOUSE_MOVE and MOUSE_EXIT events are translated into new events. Events with id ObjectList.MOUSE_ENTER_ITEM, MOUSE_EXIT_ITEM and MOUSE_MOVE_ITEM are generated when the mouse enters, leaves or moves within an item (the latter only being useful when items have different `parts'). The methods highlightRect and itemBounds may be useful in handling these events.
Field Summary | |
static int | ALWAYS
Indicates a scrollbar should always be displayed. |
static int | IFNEEDED
Indicates a scrollbar should be displayed only if needed. |
static int | MOUSE_ENTER_ITEM
id for Events which call for highlighting an item. |
static int | MOUSE_EXIT_ITEM
id for Events which call for un-highlighting an item. |
static int | MOUSE_MOVE_ITEM
id for Events which call for a change in highlighting due to mouse movement within an item. |
static int | NEVER
Indicates a scrollbar should never be displayed. |
Fields inherited from class java.awt.Component | |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Constructor Summary | |
ObjectList(int nColumns,
int nRows)
Creates a new ObjectList of nColumns*nRows characters and not allowing multiple selections. |
|
ObjectList(int nColumns,
int nRows,
boolean multipleSelections)
Creates a new ObjectList of nColumns*nRows characters and specifying whether multiple selections are allowed or not. |
Method Summary | |
void | addItem(java.lang.Object item)
Adds item as a root node at the end. |
void | addItem(java.lang.Object item,
int index)
Adds item as a root node at a particular position in the list. |
void | addItems(java.lang.Object[] items,
boolean enabled,
boolean hidden)
Adds a sequence of items as roots at the end of object list. |
void | addItems(java.lang.Object[] items)
Adds a sequence of items as roots at the end of object list. |
boolean | allowsMultipleSelections()
Returns true if this list allows multiple selections. |
void | clear()
Clears the list. |
void | close(java.lang.Object item)
Close this item, hiding its children (if any). |
void | delItem(java.lang.Object item)
Delete a root item from the list. |
void | deselectAll()
Deselect all selected items. |
void | deselect(java.lang.Object item)
Deselects the item. |
void | disable(java.lang.Object item)
Disable this item. |
boolean | duplicatesIgnored()
Returns whether duplicated items inserted into the list are ignored. |
void | enable(java.lang.Object item)
Enable this item. |
void | enable(java.lang.Object item,
boolean value)
Enable or Disable this item according to value. |
java.lang.Object[] | getChildren(java.lang.Object item)
Get the children associated with item. |
int | getIndentation(int i)
Get the indentation (in pixels) for each level of the hierarchy. |
java.lang.Object | getParent(java.lang.Object item)
Get the parent associated with item. |
java.lang.Object | getSelectedItem()
Get the selected item or null if no item is selected. |
java.lang.Object[] | getSelectedItems()
Returns the selected items on the list. |
java.lang.String | getString(java.lang.Object item)
Return a descriptive string for item. |
int | getXScrolling()
Returns the code for whether X (horizontal) scroll bar should appear. |
int | getYScrolling()
Returns the code for whether Y (vertical) scroll bar should appear. |
boolean | handleEvent(java.awt.Event e)
Event handler: handles item selection and mouse documentation. |
void | hide(java.lang.Object item)
Hide this item. |
void | highlightRect(int x,
int y,
int width,
int height)
Draws a highlighting rectangle, using XOR, with the given position and size. |
void | highlightRect(java.awt.Rectangle r)
Draws a highlighting rectangle, using XOR. |
void | ignoreDuplicates(boolean value)
Specifies whether duplicated items inserted into the list should be ignored instead of signalling an error. |
java.awt.Insets | insets()
|
boolean | isEnabled()
What's going on with `inheritance' of enabled/disabled? |
boolean | isEnabled(java.lang.Object item)
Is this item enabled? |
boolean | isOpenable(java.lang.Object item)
Is this item able to be opened? |
boolean | isOpen(java.lang.Object item)
Is this item opened? |
boolean | isSelected(java.lang.Object item)
Returns true if the item has been selected; false otherwise. |
boolean | isShowing(java.lang.Object item)
Is this item showing (visible and parent is open and showing) ? |
boolean | isVisible(java.lang.Object item)
Is this item visible? |
java.awt.Rectangle | itemBounds(java.lang.Object item)
Returns the bounding rectangle of the item on the ObjectList. |
void | layout()
layout the panel. |
void | makeVisible(java.lang.Object item)
Scroll the panel to force item (and its children) to be visible. |
java.awt.Dimension | minimumSize()
Returns the minimum dimensions needed for the object list. |
void | open(java.lang.Object item)
Open this item, revealing its children (if any). |
java.awt.Dimension | paintItem(java.awt.Graphics g,
java.lang.Object item)
Paint item at the current position in g. |
void | paint(java.awt.Graphics g)
Paint the display. |
java.awt.Dimension | preferredSize()
Returns the preferred dimensions needed for the object list. |
void | replaceItem(java.lang.Object newItem,
java.lang.Object oldItem)
Replaces the root oldItem with newItem. |
void | select(java.lang.Object item)
Selects the item. |
void | setIndentation(int i)
Set the indentation (in pixels) for each level of the hierarchy. |
void | setMultipleSelections(boolean v)
Sets whether this list should allow multiple selections or not. |
void | setXScrolling(int xscrolling)
Specify whether x scrollbars should be displayed always, never or only when needed. |
void | setYScrolling(int yscrolling)
Specify whether y scrollbars should be displayed always, never or only when needed. |
void | show(java.lang.Object item)
Show this item. |
void | show(java.lang.Object item,
boolean value)
Show or Hide this item according to value. |
void | update(java.awt.Graphics g)
Update the display. |
Methods inherited from class java.awt.Panel | |
addNotify |
Methods inherited from class java.awt.Container | |
add, add, add, add, add, addContainerListener, addImpl, addNotify, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponentAt, getComponentAt, getComponent, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, paint, paramString, preferredSize, printComponents, print, processContainerEvent, processEvent, removeAll, remove, remove, removeContainerListener, removeNotify, setLayout, update, validate, validateTree |
Methods inherited from class java.awt.Component | |
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paint, paramString, postEvent, preferredSize, prepareImage, prepareImage, printAll, print, processComponentEvent, processEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate |
Methods inherited from class java.lang.Object | |
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait |
Field Detail |
public static final int MOUSE_ENTER_ITEM
public static final int MOUSE_EXIT_ITEM
public static final int MOUSE_MOVE_ITEM
public static final int IFNEEDED
public static final int ALWAYS
public static final int NEVER
Constructor Detail |
public ObjectList(int nColumns, int nRows)
public ObjectList(int nColumns, int nRows, boolean multipleSelections)
nColumns
- the number of columns in characters.
nRows
- the number of rows of items.
multipleSelections
- if true then multiple selections are allowed.Method Detail |
public int getIndentation(int i)
public void setIndentation(int i)
public void setXScrolling(int xscrolling)
public int getXScrolling()
public void setYScrolling(int yscrolling)
public int getYScrolling()
public boolean duplicatesIgnored()
public void ignoreDuplicates(boolean value)
public java.awt.Insets insets()
public java.awt.Dimension preferredSize()
public java.awt.Dimension minimumSize()
public void layout()
public boolean isEnabled()
public void addItem(java.lang.Object item)
public void addItem(java.lang.Object item, int index)
public void addItems(java.lang.Object[] items, boolean enabled, boolean hidden)
public void addItems(java.lang.Object[] items)
public void replaceItem(java.lang.Object newItem, java.lang.Object oldItem)
public void clear()
public void delItem(java.lang.Object item)
public java.lang.Object getSelectedItem()
public java.lang.Object[] getSelectedItems()
public void select(java.lang.Object item)
public void deselect(java.lang.Object item)
public void deselectAll()
public boolean isSelected(java.lang.Object item)
public boolean allowsMultipleSelections()
public void setMultipleSelections(boolean v)
public boolean isEnabled(java.lang.Object item)
public void enable(java.lang.Object item)
public void disable(java.lang.Object item)
public void enable(java.lang.Object item, boolean value)
public java.lang.Object[] getChildren(java.lang.Object item)
public java.lang.Object getParent(java.lang.Object item)
public boolean isOpen(java.lang.Object item)
public boolean isOpenable(java.lang.Object item)
public void open(java.lang.Object item)
public void close(java.lang.Object item)
public boolean isVisible(java.lang.Object item)
public boolean isShowing(java.lang.Object item)
public void show(java.lang.Object item)
public void hide(java.lang.Object item)
public void show(java.lang.Object item, boolean value)
public void makeVisible(java.lang.Object item)
public void update(java.awt.Graphics g)
public void paint(java.awt.Graphics g)
public boolean handleEvent(java.awt.Event e)
public java.awt.Dimension paintItem(java.awt.Graphics g, java.lang.Object item)
public java.lang.String getString(java.lang.Object item)
public java.awt.Rectangle itemBounds(java.lang.Object item)
public void highlightRect(int x, int y, int width, int height)
public void highlightRect(java.awt.Rectangle r)
Overview | Package | Class | Tree | Deprecated | Index | Help | |||
PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |