sdm
Class CTable

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JTable
                          |
                          +--sdm.CTable

public class CTable
extends javax.swing.JTable
implements javax.swing.event.TableColumnModelListener, java.awt.event.MouseListener, javax.swing.Scrollable, java.awt.event.ActionListener

This class extends JTable to include some features useful for displaying multiple information in an organized manner. We added features so that the table can insert, replace and delete any of the rows and columns as needed. Also this class implements TableColumnListener, MouseListener and ListSelectionListener to know when thing are modified.

See Also:
Serialized Form

Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
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
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, 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
 
Constructor Summary
CTable()
          Create an empty table
CTable(java.lang.String[] rownames, java.lang.String[] colnames)
          Creates a table with the given device names and property names.
CTable(java.lang.String[] rownames, java.lang.String[] colnames, int[] colWidth)
          Creates a table with the given device names and property names and also the column width.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
          handle the popup menu insert, replace and delete
 int getColumnWidth(int i)
          Returns the size of the column at index i (not include the row head column)
 int[] getColumnWidths()
          Returns the array of column widths to the utility.
 java.lang.String[] getDeviceNames()
          Returns the array of device names.
 java.lang.String[] getPropertyNames()
          Returns the array of property names.
 boolean getTableState()
          Return true if table state change otherwise return false.
 void insertDevice(int position, java.lang.String newName)
          Insert device at given index
 void insertProperty(int position, java.lang.String newName)
          Insert property at given index
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
          popup a menu when right mouse down
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void removeDevice(int position)
          Remove device at given index
 void removeProperty(int position)
          Remove property at given index
 void setColumnWidth(int index, int size)
          to be implemented next release sets the column width of the selected column index
 void setColumnWidths(int[] width)
          to be implemented next release
 void setDeviceName(int r, java.lang.String newName)
          This method is called synchronous to setDeviceName at row r.
 void setDeviceNames(java.lang.String[] newNames)
          This method is called synchronous to set deviceNames.
 void setPropertyName(int c, java.lang.String newName)
          Set propertyName at column c.
 void setPropertyNames(java.lang.String[] newNames)
          This method is called synchronous to setPropertyNames.
 
Methods inherited from class javax.swing.JTable
addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, clearSelection, columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, convertColumnIndexToModel, convertColumnIndexToView, createDefaultColumnsFromModel, createScrollPaneForTable, 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, getRowMargin, getRowSelectionAllowed, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedColumn, getSelectedColumnCount, getSelectedColumns, getSelectedRow, getSelectedRowCount, getSelectedRows, getSelectionBackground, getSelectionForeground, getSelectionModel, getShowHorizontalLines, getShowVerticalLines, getTableHeader, getToolTipText, getUI, getUIClassID, getValueAt, isCellEditable, isCellSelected, isColumnSelected, isEditing, isManagingFocus, isRowSelected, moveColumn, prepareEditor, prepareRenderer, removeColumn, removeColumnSelectionInterval, removeEditor, removeRowSelectionInterval, reshape, rowAtPoint, selectAll, setAutoCreateColumnsFromModel, setAutoResizeMode, setCellEditor, setCellSelectionEnabled, setColumnModel, setColumnSelectionAllowed, setColumnSelectionInterval, setDefaultEditor, setDefaultRenderer, setEditingColumn, setEditingRow, setGridColor, setIntercellSpacing, setModel, setPreferredScrollableViewportSize, setRowHeight, setRowMargin, setRowSelectionAllowed, setRowSelectionInterval, setSelectionBackground, setSelectionForeground, setSelectionMode, setSelectionModel, setShowGrid, setShowHorizontalLines, setShowVerticalLines, setTableHeader, setUI, setValueAt, sizeColumnsToFit, sizeColumnsToFit, tableChanged, updateUI, valueChanged
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setCursor, setLayout, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, contains, createImage, createImage, disable, dispatchEvent, enable, enable, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hide, 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, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CTable

public CTable()
Create an empty table

CTable

public CTable(java.lang.String[] rownames,
              java.lang.String[] colnames)
Creates a table with the given device names and property names.
Parameters:
rownames - array of Devices.
colnames - array of properties.

CTable

public CTable(java.lang.String[] rownames,
              java.lang.String[] colnames,
              int[] colWidth)
Creates a table with the given device names and property names and also the column width.
Parameters:
rownames - This is an array of Devices.
colnames - This is an array of properties.
colWidth - This is an array of column Widths.
Method Detail

setDeviceName

public void setDeviceName(int r,
                          java.lang.String newName)
This method is called synchronous to setDeviceName at row r.
Parameters:
r - row index for new device
newName - new device names to be set.

setDeviceNames

public void setDeviceNames(java.lang.String[] newNames)
This method is called synchronous to set deviceNames.
Parameters:
newNames - The array of device names that are passed.

getDeviceNames

public java.lang.String[] getDeviceNames()
Returns the array of device names.

setPropertyName

public void setPropertyName(int c,
                            java.lang.String newName)
Set propertyName at column c.
Parameters:
c - column index for new property
newName - new property names to be set.

setPropertyNames

public void setPropertyNames(java.lang.String[] newNames)
This method is called synchronous to setPropertyNames.
Parameters:
newNames - The array of property names that are passed.

getPropertyNames

public java.lang.String[] getPropertyNames()
Returns the array of property names.

getColumnWidth

public int getColumnWidth(int i)
Returns the size of the column at index i (not include the row head column)
Parameters:
the - index of column.

getColumnWidths

public int[] getColumnWidths()
Returns the array of column widths to the utility.
Returns:
array of column widths

setColumnWidths

public void setColumnWidths(int[] width)
to be implemented next release

setColumnWidth

public void setColumnWidth(int index,
                           int size)
to be implemented next release sets the column width of the selected column index
Parameters:
index - index of the column
size - size of the column

getTableState

public boolean getTableState()
Return true if table state change otherwise return false.

removeDevice

public void removeDevice(int position)
Remove device at given index
Parameters:
position - device index to be removed

removeProperty

public void removeProperty(int position)
Remove property at given index
Parameters:
position - property index to be removed

insertDevice

public void insertDevice(int position,
                         java.lang.String newName)
Insert device at given index
Parameters:
position - device index to be inserted
newName - new device name to be inserted

insertProperty

public void insertProperty(int position,
                           java.lang.String newName)
Insert property at given index
Parameters:
position - property index to be inserted
newName - new property name to be inserted

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
handle the popup menu insert, replace and delete
Specified by:
actionPerformed in interface java.awt.event.ActionListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
popup a menu when right mouse down
Specified by:
mousePressed in interface java.awt.event.MouseListener
Parameters:
e - A MouseEvent

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener