: Class TsTable

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ## TsBiff 1.3
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## ts.ui
Class TsTable

    java.lang.Object
      |
      +--java.awt.Component
            |
            +--java.awt.Container
                  |
                  +--javax.swing.JComponent
                        |
                        +--javax.swing.JTable
                              |
                              +--ts.ui.TsTable

All Implemented Interfaces:
  javax.accessibility.Accessible, javax.swing.event.CellEditorListener, java.util.EventListener, java.awt.image.ImageObserver, javax.swing.event.ListSelectionListener, java.awt.MenuContainer, javax.swing.Scrollable, java.io.Serializable, javax.swing.event.TableColumnModelListener, javax.swing.event.TableModelListener

Direct Known Subclasses:
  View

public class TsTable
extends javax.swing.JTable

A table for viewing data in a two-dimensional grid. The table can have any number of columns and rows. Columns can be resized by use of mouse drag. It's possible to hide columns from the grid. The class provide two interfaces:

1. A callback interface which can be implemented by classes that want to receive information about table selections.
2. An interface allowing the implementor to preprocess a value before it's set in a cell and either discard or allow the new value to be commited.

Version:
  $Id: TsTable.java,v 1.6 1999/02/21 08:47:23 hauk Exp $
Author:
  Jan-Henrik Haukeland
See Also:
  `TsTableModel`, Serialized Form

Inner Class Summary
`static interface` | `TsTable.Callback` Objects implementing this interface can be passed to the TsTable class, to have their singleClick() or doubleClick() functions called in response to single or double click in the Table.
`static interface` | `TsTable.Cellmask` Objects implementing this interface can be passed to the TsTable class to test a value before it's commited in a cell.

Inner classes inherited from class javax.swing.JTable
`javax.swing.JTable.AccessibleJTable`

Inner classes inherited from class javax.swing.JComponent
`javax.swing.JComponent.AccessibleJComponent`

Inner classes inherited from class java.awt.Container
`java.awt.Container.AccessibleAWTContainer`

Inner classes inherited from class java.awt.Component
`java.awt.Component.AccessibleAWTComponent`

Field Summary
`protected TsTable.Callback` | `myCallBack`
`protected TsTable.Cellmask` | `myCellMask`
`protected TsTableModel` | `myTableModel`

Fields inherited from class javax.swing.JTable
`AUTO_RESIZE_ALL_COLUMNS, AUTO_RESIZE_LAST_COLUMN, AUTO_RESIZE_NEXT_COLUMN, AUTO_RESIZE_OFF, AUTO_RESIZE_SUBSEQUENT_COLUMNS, autoCreateColumnsFromModel, autoResizeMode, cellEditor, cellSelectionEnabled, columnModel, dataModel, defaultEditorsByColumnClass, defaultRenderersByColumnClass, editingColumn, editingRow, editorComp, gridColor, preferredViewportSize, rowHeight, rowMargin, rowSelectionAllowed, selectionBackground, selectionForeground, selectionModel, showHorizontalLines, showVerticalLines, tableHeader`

Fields inherited from class javax.swing.JComponent
`accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW`

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
`TsTable()` Create a new empty Table
`TsTable(java.lang.Object[] titles, java.lang.Object[][] data)` Create a new Table with the submitted titles and dataset

Method Summary
`protected void` | `addListeners()` Callback handling
`void` | `clear()` Remove all cells from the TsTable and from the dataset
`void` | `computeColumnWidth()` Compute the minimum size of each column.
`java.lang.Object[]` | `getRow(int index)` Get the row at index as an Object array
`java.util.Vector` | `getRowVector(int index)` Get the row at index.
`boolean` | `isCellEditable(int row, int column)` Overridden to allow callback object to set edit permission for the cell
`boolean` | `isSelected()` Return true if a row in the grid is selected
`int` | `selected()` Get the selected row index
`void` | `setCallBack(TsTable.Callback c)` Set object to call back to on table selection
`void` | `setCellMask(TsTable.Cellmask c)` Set object to call back to on edit
`void` | `setData(java.util.Vector data)` Set a new Data set for the table
`void` | `setEditable(boolean b)` Set if cells in the table could be edited.
`void` | `setHiddenColumns(int hidden)` Set the number of hidden columns in the Table.
`void` | `setModel(TsTableModel model)` Set a new DataModel for the table.
`void` | `setTitles(java.util.Vector titles)` Set new column titles for the Table
`void` | `setValueAt(java.lang.Object aValue, int row, int column)` Overridden to allow callback object to check if the value is legal before changes in a cell is commited

Methods inherited from class javax.swing.JTable
`addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, changeSelection, clearSelection, columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, configureEnclosingScrollPane, convertColumnIndexToModel, convertColumnIndexToView, createDefaultColumnModel, createDefaultColumnsFromModel, createDefaultDataModel, createDefaultEditors, createDefaultRenderers, createDefaultSelectionModel, createDefaultTableHeader, createScrollPaneForTable, doLayout, editCellAt, editCellAt, editingCanceled, editingStopped, getAccessibleContext, getAutoCreateColumnsFromModel, getAutoResizeMode, getCellEditor, getCellEditor, getCellRect, getCellRenderer, getCellSelectionEnabled, getColumn, getColumnClass, getColumnCount, getColumnModel, getColumnName, getColumnSelectionAllowed, getDefaultEditor, getDefaultRenderer, getEditingColumn, getEditingRow, getEditorComponent, getGridColor, getIntercellSpacing, getModel, getPreferredScrollableViewportSize, getRowCount, getRowHeight, getRowHeight, getRowMargin, getRowSelectionAllowed, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedColumn, getSelectedColumnCount, getSelectedColumns, getSelectedRow, getSelectedRowCount, getSelectedRows, getSelectionBackground, getSelectionForeground, getSelectionModel, getShowHorizontalLines, getShowVerticalLines, getTableHeader, getToolTipText, getUI, getUIClassID, getValueAt, initializeLocalVars, isCellSelected, isColumnSelected, isEditing, isFocusTraversable, isManagingFocus, isRowSelected, moveColumn, paramString, prepareEditor, prepareRenderer, processKeyBinding, removeColumn, removeColumnSelectionInterval, removeEditor, removeNotify, removeRowSelectionInterval, resizeAndRepaint, rowAtPoint, selectAll, setAutoCreateColumnsFromModel, setAutoResizeMode, setCellEditor, setCellSelectionEnabled, setColumnModel, setColumnSelectionAllowed, setColumnSelectionInterval, setDefaultEditor, setDefaultRenderer, setEditingColumn, setEditingRow, setGridColor, setIntercellSpacing, setModel, setPreferredScrollableViewportSize, setRowHeight, setRowHeight, setRowMargin, setRowSelectionAllowed, setRowSelectionInterval, setSelectionBackground, setSelectionForeground, setSelectionMode, setSelectionModel, setShowGrid, setShowHorizontalLines, setShowVerticalLines, setTableHeader, setUI, sizeColumnsToFit, sizeColumnsToFit, tableChanged, unconfigureEnclosingScrollPane, updateUI, valueChanged`

Methods inherited from class javax.swing.JComponent
`addAncestorListener, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isLightweightComponent, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update`

Methods inherited from class java.awt.Container
`add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree`

Methods inherited from class java.awt.Component
`action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### myCallBack

    protected TsTable.Callback myCallBack

### myCellMask

    protected TsTable.Cellmask myCellMask

### myTableModel

    protected TsTableModel myTableModel

Constructor Detail

### TsTable

    public TsTable()

  Create a new empty Table

### TsTable

    public TsTable(java.lang.Object[] titles,
                   java.lang.Object[][] data)

  Create a new Table with the submitted titles and dataset
  Parameters:
    `titles` - table titles
    `data` - table data

Method Detail

### setEditable

    public void setEditable(boolean b)

  Set if cells in the table could be edited.
  Parameters:
    `true` - if the table will allow edit in cells else false

### setHiddenColumns

    public void setHiddenColumns(int hidden)

  Set the number of hidden columns in the Table. Columns can only be hidden from left to right in the column set. I.e. if the number of hidden columns is set to 1, then the first column in the table is hidden, that is, not displayed in the grid. If the number is 2 then the first two columns are hidden and so on. If hidden columns are enabled with this method, you should still work with the Table as if no columns was hidden. This method will fire a TableStructureChanged event which will reset any changes in the table ui, e.g. column size, cell editors etc. (In other words call this method first before you do stuff like that)
  Parameters:
    `hidden` - number of columns that should be hidden.

### setModel

    public void setModel(TsTableModel model)

  Set a new DataModel for the table. The model include both data for cells and titles
  Parameters:
    `model` - A new TsTableModel

### setData

    public void setData(java.util.Vector data)

  Set a new Data set for the table
  Parameters:
    `data` - A new data set

### setTitles

    public void setTitles(java.util.Vector titles)

  Set new column titles for the Table
  Parameters:
    `titles` - Column titles

### setCallBack

    public void setCallBack(TsTable.Callback c)

  Set object to call back to on table selection

### setCellMask

    public void setCellMask(TsTable.Cellmask c)

  Set object to call back to on edit

### getRowVector

    public java.util.Vector getRowVector(int index)

  Get the row at index. This method will (of course) also return values in any hidden columns.
  Returns:
    A vector representing the row at row index

### getRow

    public java.lang.Object[] getRow(int index)

  Get the row at index as an Object array
  Returns:
    the row at row index

### selected

    public int selected()

  Get the selected row index
  Returns:
    the selected row index

### isSelected

    public boolean isSelected()

  Return true if a row in the grid is selected
  Returns:
    true if a row is selected

### clear

    public void clear()

  Remove all cells from the TsTable and from the dataset

### computeColumnWidth

    public void computeColumnWidth()

  Compute the minimum size of each column. The algorithm is to loop through every cell in each column and set the width to the widest cell in the column. The table headers is not included in the computing. This is by design. Note!This method should be used with caution since it's cpu demanding for large dataset. The method could also give some unespected results if the table is put in a viewport (which is normal) and the viewport width is less than the combined width of the columns, then some of the columns may not be visible in the viewport.

### setValueAt

    public void setValueAt(java.lang.Object aValue,
                           int row,
                           int column)

  Overridden to allow callback object to check if the value is legal before changes in a cell is commited
  Overrides:
    `setValueAt` in class `javax.swing.JTable`
  Parameters:
    `aValue` - - the new value
    `row` - - the row whose value is to be changed
    `column` - - the column whose value is to be changed

### isCellEditable

    public boolean isCellEditable(int row,
                                  int column)

  Overridden to allow callback object to set edit permission for the cell
  Overrides:
    `isCellEditable` in class `javax.swing.JTable`
  Parameters:
    `row` - - the row whose value is to be looked up
    `column` - - the column whose value is to be looked up

### addListeners

    protected void addListeners()

  Callback handling

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ## TsBiff 1.3
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD