Table Widget
Introduction <<Model>> Demo Tutorial Documentation Download Data Model
This component's data is built upon String elements. Arrays of such Strings make-up rows and columns. Each column of Strings has a title associated with it.
Rows and columns of data can be added or deleted dynamically. Further, any element at a [row, column] can be reset to another string. In future versions, replacement of rows/columns by new string arrays will be supported.
Layout
Click here[5k] for a sample screen shot of the Table widget.
Column titles are displayed at the top of the Table, and the column data is displayed below the header. Narrow regions between consecutive coulmn-titles are active and can be dragged to resize widths of columns. Although by default all columns are of equal width, the user (a Java developer) of this component can explicitely specify relative weights for columns. A scrollbar is displayed whenever necessary.
Event Model
This widget allows two modes of user-interaction:
- Actions with single mouse-clicks: In this configuration, single mouse-clicks cause action events (ActionEvent.ACTION_PERFORMED), while mouse-movement causes selection (ItemEvent.SELECTED) and deselection (ItemEvent.DESELECTED).
- Actions with double mouse-clicks: This is a more elaborate feature in which double mouse-clicks cause action events, and single mouse-clicks cause selection and deselection events. Multiple selection of rows/columns/elements is possible in this setup.
Both these modes of interaction can be enforced element-level, row-level or column-level. Element-level model allows interaction with data elements directly. In row-level model, an event over a data element applies to all the elements in the same row; while in column-level model, the events apply to all the elements in the same column.
By default, this widget follows the row-level double mouse-click model but this can be changed dynamically.
Selections can also be done manually. However, this will not trigget the event listeners
Event Listeners
The Table Widget supports the folling listeners.
- Action Listener: To capture ActionEvent.ACTION_PERFORMED events.
- Item Listener: To capture ItemEvent.SELECTED and ItemEvent.DESELECTED events. These occur when a row/column/element is selected.
- Mouse Listener: To capture MouseEvent.MOUSE_ENTERED, MouseEvent.MOUSE_EXITED, MouseEvent.MOUSE_CLICKED, MouseEvent.MOUSE_PRESSED and MouseEvent.MOUSE_RELEASED events that occur over the Table Widget.
- Mouse motion Listener: To capture MouseEvent.MOUSE_MOVED and MouseEvent.MOUSE_DRAGGED events that occur over the Table Widget.
The users of the Table Widget must implement appropriate listener objects and call addXXXListener methods on Table Widget objects. The approach is similar to adding listeners to any Java AWT component.
Customization of Look and Feel
In addition to customization of event model for user-interaction, the following attributes are configurable:
- Fonts: Fonts for the header and data region. Height of the header and inter-line spacing of the data region depend on the font selections.
- Inter-row spacing: Inter-row spacing (relative) can be set. For example, the user can specify a factor 1.5 or 2.0 to indicate one-and-half or double spacing.
- Colors:
- Foreground and background colors for the header.
- Foreground, background, reverse-foreground and reverse-foreground colors dor the data region.
- Color for the active draggable regions.
All these can be applied to or changed for specific rows or columns also.
- Size: Although its constructor requires width and height (both in pixels) arguments, this widget gets resized based on the container's layout mechanism. Please be aware that Java's component resizing depends on the containers's layout.
- Separators: Supports row and column separator lines.
- Drggable columns: Can be enabled or disabled. When enabled (default), active areas between columns can be dragged to resize columns.
- Column Width: By default, all columns are of equal-width. Relative weights can however be set.
Last modified: Fri Jun 18 11:55:16 India Standard Time 1999
© Subbu Allamaraju 1998, 1999. All rights reserved.
All copyrights and trademarks acknowledged.