com.quadrique.jbuildingblocks.gui
Class Table
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JTable
com.quadrique.jbuildingblocks.gui.Table
- All Implemented Interfaces:
- MouseListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, CellEditorListener, ListSelectionListener, RowSorterListener, TableColumnModelListener, TableModelListener, Scrollable
public class Table
- extends JTable
- implements MouseListener
This class is the base class for all the tables. It provides a framework and handles all the common features.
A typical table implementation would be of the form:
public class DesktopPanelFrameAlarmsTable extends Table
{
public DesktopPanelFrameAlarmsTable()
{
// internal members
super();
// set the model
String[] lColumnNames = new String[4];
lColumnNames[0] = "Date";
lColumnNames[1] = "Type";
lColumnNames[2] = "Description";
lColumnNames[3] = "Details";
mModel = new DesktopPanelFrameAlarmsTableModel(lColumnNames);
super.setModel(mModel);
// set renderer
TableColumn lTc = null;
DesktopPanelFrameAlarmsTableCellRenderer lRenderer = null;
for (int i=0; i
A typical way of incorporating the table and a button area in a panel is shown below:
// use a BorderLayout
getContentPane().setLayout(new BorderLayout());
// build the table
mTable = new DesktopPanelFrameAlarmsTable();
TableScrollPane lPanel = new TableScrollPane(mTable);
mTable.setData(zAlarms);
getContentPane().add(lPanel,"Center");
// add the buttons bar
mButtonArea = new ButtonArea(true,false);
mButtonArea.addButton("Close",KeyEvent.VK_C,"",null,0);
mButtonArea.addButton("Refresh",KeyEvent.VK_R,"Retrieve the alarms from the server",null,1);
mButtonArea.addButtonSelectedEventListener(this);
...
- Author:
- Hervé Rivere
- See Also:
- Serialized Form
|
Constructor Summary |
Table()
Constructor |
| Methods inherited from class javax.swing.JTable |
addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, changeSelection, clearSelection, columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, convertColumnIndexToModel, convertColumnIndexToView, convertRowIndexToModel, convertRowIndexToView, createDefaultColumnsFromModel, createScrollPaneForTable, doLayout, editCellAt, editCellAt, editingCanceled, editingStopped, getAccessibleContext, getAutoCreateColumnsFromModel, getAutoCreateRowSorter, getAutoResizeMode, getCellEditor, getCellEditor, getCellRect, getCellRenderer, getCellSelectionEnabled, getColumn, getColumnClass, getColumnCount, getColumnModel, getColumnName, getColumnSelectionAllowed, getDefaultEditor, getDefaultRenderer, getDragEnabled, getDropLocation, getDropMode, getEditingColumn, getEditingRow, getEditorComponent, getFillsViewportHeight, getGridColor, getIntercellSpacing, getModel, getPreferredScrollableViewportSize, getPrintable, getRowCount, getRowHeight, getRowHeight, getRowMargin, getRowSelectionAllowed, getRowSorter, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedColumn, getSelectedColumnCount, getSelectedColumns, getSelectedRow, getSelectedRowCount, getSelectedRows, getSelectionBackground, getSelectionForeground, getSelectionModel, getShowHorizontalLines, getShowVerticalLines, getSurrendersFocusOnKeystroke, getTableHeader, getToolTipText, getUI, getUIClassID, getUpdateSelectionOnSort, getValueAt, isCellEditable, isCellSelected, isColumnSelected, isEditing, isRowSelected, moveColumn, prepareEditor, prepareRenderer, print, print, print, print, print, removeColumn, removeColumnSelectionInterval, removeEditor, removeNotify, removeRowSelectionInterval, rowAtPoint, selectAll, setAutoCreateColumnsFromModel, setAutoCreateRowSorter, setAutoResizeMode, setCellEditor, setCellSelectionEnabled, setColumnModel, setColumnSelectionAllowed, setColumnSelectionInterval, setDefaultEditor, setDefaultRenderer, setDragEnabled, setDropMode, setEditingColumn, setEditingRow, setFillsViewportHeight, setGridColor, setIntercellSpacing, setModel, setPreferredScrollableViewportSize, setRowHeight, setRowHeight, setRowMargin, setRowSelectionAllowed, setRowSelectionInterval, setRowSorter, setSelectionBackground, setSelectionForeground, setSelectionMode, setSelectionModel, setShowGrid, setShowHorizontalLines, setShowVerticalLines, setSurrendersFocusOnKeystroke, setTableHeader, setUI, setUpdateSelectionOnSort, setValueAt, sizeColumnsToFit, sizeColumnsToFit, sorterChanged, tableChanged, updateUI, valueChanged |
| Methods inherited from class javax.swing.JComponent |
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
| Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate |
| Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
Table
public Table()
- Constructor
setHeaderRowHeight
public void setHeaderRowHeight(int zNbOfPixels)
- to set the height of the header row (to set the height of the regular rows, use "setRowHeight()"
- Parameters:
zNbOfPixels - the number of pixels to use
setPopupMenu
public void setPopupMenu(MenuPopup zPopupMenu)
- set the popup menu that is used for this table
- Parameters:
zPopupMenu - the popup menu to use for the table
getPopupMenu
public MenuPopup getPopupMenu()
- Returns:
- a reference to the PopupMenu instance for this table (can be null)
useModelColumnIds
public void useModelColumnIds()
- Sets for each column a unique identifier corresponding to the actual
ordering of the model.
This is needed to properly handle the reordering of columns by the end
user: you simply need to call this method upon initialization and you
can then call getModelColumnId() to retrieve the model column id even
if the end user has modified the order of the columns that are displayed.
getModelColumnId
public int getModelColumnId(int zColumnId)
- Parameters:
zColumnId - the identifier of the column
- Returns:
- the model column identifier corresponding to the given
column index.
- See Also:
useModelColumnIds()
useColumnHeaderSorting
public void useColumnHeaderSorting(TableSorterModel zModel)
- Set up the table for column header sorting.
The derived class has to implement sort() for the actual sorting to
be performed.
- Parameters:
zModel - the TableSorterModel instance
setMinimumWidth
public void setMinimumWidth(int[] zMinWidth)
- Sets the minimum width of the columns
If the width of the table is less than the overall minimum width, the
horizontal scrollbar will be displayed so that the minimum width is
respected.
If the width of the table is more than the overall minimum width, the
horizontal scrollbar will not be displayed and the columns will be
expanded to use the extra space (unless you set the maximum width with
a call to setMaximumWidth()).
- Parameters:
zMinWidth - an array of integer value (the minimum width of the
corresponding column in pixels). Please note that there must be an entry
for each of the columns (i.e. the array size must be equal to the number
of columns)- See Also:
setMaximumWidth(int[])
setMaximumWidth
public void setMaximumWidth(int[] zMaxWidth)
- Sets the maximum width of the columns.
If you do not want to impose a limit on the maximum size of the column,
use 0.
- Parameters:
zMaxWidth - the array of max width, one entry for each column- See Also:
setMinimumWidth(int[])
getMinimumWidth
public int getMinimumWidth()
- Returns:
- the minimum width of the table.
addSelectionListener
public void addSelectionListener(SelectionListener zListener)
- Call this method to receive a SelectionEvent whenever a new selection
is perfomed in this component
- Parameters:
zListener - Reference to the object implementing the
SelectionListener interface.
removeSelectionListener
public void removeSelectionListener(SelectionListener zListener)
- Call this method to remove a previously registered listener
- Parameters:
zListener - Reference to the object implementing the
SelectionListener interface.
mouseClicked
public void mouseClicked(MouseEvent e)
- The mouse listener interface
- Specified by:
mouseClicked in interface MouseListener
- Parameters:
e - the mouse event- See Also:
MouseListener
mouseEntered
public void mouseEntered(MouseEvent e)
- The mouse listener interface
- Specified by:
mouseEntered in interface MouseListener
- Parameters:
e - the mouse event- See Also:
MouseListener
mouseExited
public void mouseExited(MouseEvent e)
- The mouse listener interface
- Specified by:
mouseExited in interface MouseListener
- Parameters:
e - the mouse event- See Also:
MouseListener
mousePressed
public void mousePressed(MouseEvent e)
- The mouse listener interface
- Specified by:
mousePressed in interface MouseListener
- Parameters:
e - the mouse event- See Also:
MouseListener
mouseReleased
public void mouseReleased(MouseEvent e)
- The mouse listener interface
- Specified by:
mouseReleased in interface MouseListener
- Parameters:
e - the mouse event- See Also:
MouseListener
getSelectionEvent
public SelectionBaseEvent getSelectionEvent()
- Returns:
- the last selection event (can be null if there hasn't been
any selection)
selectRowAndNotifyListeners
public void selectRowAndNotifyListeners(int zRowNb)
- This method is used to programmaticaly select a row in the table. It also
takes care of notifying the selectionListeners of the new selection
- Parameters:
zRowNb - the row number
Copyright © 2001-2009 Quadrique Corporation. All Rights Reserved.