Rational Developer for Power Systems Software
V7.6

com.ibm.etools.iseries.ui
Class JFormattedTable

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JTable
                  extended by com.ibm.etools.iseries.ui.JFormattedTable
All Implemented Interfaces:
JFormattedComponent, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, CellEditorListener, ListSelectionListener, RowSorterListener, TableColumnModelListener, TableModelListener, Scrollable

public class JFormattedTable
extends JTable
implements JFormattedComponent, Serializable

JFormattedTable extends javax.swing.JTable and implements com.ibm.etools.iseries.ui.JFormattedComponent. It allows you to easily access and manipulate AS/400 database data when you use DefaultTableModel as the TableModel and populate the data through ListManager bean.

JFormattedTable supports editcode, editword, formatting, and verification capabilities for AS/400 data based on each table column. To allow for these capabilities, you should use JFormattedTableColumn inside JFormattedTable and specify the column's cellEditor and cellRenderer as one of the following JFormatted cell editors or renderers: JFormattedTextFieldCellEditor, JFormattedComboBoxCellEditor, or JFormattedLabelCellRenderer.

The default value of JFormattedTable's autoCreateColumnsFromModel property is true. If you create a JFormattedTable with a table model, you can let JFormattedTable automatically create table columns, then customize these columns.

For example:

 String[] columnNames = {"ItemNo", "Model"}; // column names
 String[][] items = {  {"00001", "2000AB1"}, {"00002", "2000AB2"}};// table data
 DefaultTableModel myModel = new DefaultTableModel(items, columnNames); 
 JFormattedTable itemTable=new JFormattedTable(myModel);
 JFormattedTableColumn itemNoColumn;
 try {
        itemNoColumn = (JFormattedTableColumn)itemTable.getColumn("ItemNo");
        itemNoColumn.setCellEditable(false); // set itemNoColumn as read only
  } catch (Exception e){
        itemNoColumn = null;
 }
 
If you create a default JFormattedTable and add table columns to the JFormattedTable, you need to set the autoCreateColumnsFromModel property as false.

For example:
 
 JFormattedTable myTable=new JFormattedTable();
 myTable.setAutoCreateColumnsFromModel(false);
 JFormattedTableColumn myColumn = new JFormattedTableColumn();
 myColumn.setIdentifier("model"); 
 myColumn.setHeaderValue("Model");
 myTable.addColumn(myColumn);   
 

See Also:
JFormattedComponent, JTable, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JTable
JTable.AccessibleJTable, JTable.DropLocation, JTable.PrintMode
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static String Copyright
           
 
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 com.ibm.etools.iseries.ui.JFormattedComponent
copyright
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JFormattedTable()
          Creates a new JFormattedTable.
JFormattedTable(FieldModel fm)
          Creates a new JFormattedTable with the specified field model.
JFormattedTable(int numRows, int numColumns)
          Creates a new JFormattedTable with the numRows and numColumns of empty cells.
JFormattedTable(int numRows, int numColumns, FieldModel fm)
          Creates a new JFormattedTable with the specified field model, number of rows and columns.
JFormattedTable(Object[][] rowData, Object[] columnNames)
          Creates a new JFormattedTable with the specified data and column names.
JFormattedTable(Object[][] rowData, Object[] columnNames, FieldModel fm)
          Creates a new JFormattedTable with the specified data, column names and field model.
JFormattedTable(TableModel dm)
          Creates new JFormattedTable with the specified TableModel.
JFormattedTable(TableModel dm, FieldModel fm)
          Creates a new JFormattedTable with the specified TableModel and FieldModel.
JFormattedTable(TableModel dm, TableColumnModel cm)
          Creates a new JFormattedTable with the specified TableModel and TableColumnModel.
JFormattedTable(TableModel dm, TableColumnModel cm, ListSelectionModel sm)
          Creates a new JFormattedTable with the specified TableModel,TableColumnModel and ListSelectionModel.
JFormattedTable(Vector rowData, Vector columnNames)
          Creates a new JFormattedTable with the specified data and column names.
JFormattedTable(Vector rowData, Vector columnNames, FieldModel fm)
          Creates a new JFormattedTable with the specified data, column names and field model.
 
Method Summary
static String Copyright()
          Copyright notice.
 void createDefaultColumnsFromModel()
          Creates default table columns from table model.
 FieldModel getFieldModel()
          Gets the default field model.
 boolean isCellEditable(int row, int column)
          Returns true if the cell at row and column is editable.
 boolean isSelectionEmpty()
          Returns true if nothing is selected.
 void setFieldModel(FieldModel fm)
          Sets the default field model of the JFormattedTable.
 void setVisibleRowCount(int rows)
          Sets how many rows to make visible at once.
 
Methods inherited from class javax.swing.JTable
addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, changeSelection, clearSelection, columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, configureEnclosingScrollPane, convertColumnIndexToModel, convertColumnIndexToView, convertRowIndexToModel, convertRowIndexToView, createDefaultColumnModel, createDefaultDataModel, createDefaultEditors, createDefaultRenderers, createDefaultSelectionModel, createDefaultTableHeader, 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, initializeLocalVars, isCellSelected, isColumnSelected, isEditing, isRowSelected, moveColumn, paramString, prepareEditor, prepareRenderer, print, print, print, print, print, processKeyBinding, removeColumn, removeColumnSelectionInterval, removeEditor, removeNotify, removeRowSelectionInterval, resizeAndRepaint, 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, unconfigureEnclosingScrollPane, updateUI, valueChanged
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, 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, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, 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, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, 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, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, 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, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

Copyright

public static final String Copyright
See Also:
Constant Field Values
Constructor Detail

JFormattedTable

public JFormattedTable()
Creates a new JFormattedTable.


JFormattedTable

public JFormattedTable(Object[][] rowData,
                       Object[] columnNames)
Creates a new JFormattedTable with the specified data and column names.

Parameters:
rowData - The data for the table.
columnNames - The names of each column.

JFormattedTable

public JFormattedTable(Object[][] rowData,
                       Object[] columnNames,
                       FieldModel fm)
Creates a new JFormattedTable with the specified data, column names and field model.

Parameters:
rowData - The data for the table.
columnNames - The names of each column.
fm - The default field model for formatting and validating.

JFormattedTable

public JFormattedTable(int numRows,
                       int numColumns)
Creates a new JFormattedTable with the numRows and numColumns of empty cells.

Parameters:
numRows - The number of rows.
numColumns - The number of columns.

JFormattedTable

public JFormattedTable(int numRows,
                       int numColumns,
                       FieldModel fm)
Creates a new JFormattedTable with the specified field model, number of rows and columns.

Parameters:
numRows - The number of rows.
numColumns - The number of columns.
fm - The default field model for formatting and validating.

JFormattedTable

public JFormattedTable(FieldModel fm)
Creates a new JFormattedTable with the specified field model. The field model is used to specify the default field model of JFormattedTableColumn instances which are created from the data model of the table.

Parameters:
fm - The default field model for formatting and validating.

JFormattedTable

public JFormattedTable(Vector rowData,
                       Vector columnNames)
Creates a new JFormattedTable with the specified data and column names.

Parameters:
rowData - The data of the table.
columnNames - The names of each column.

JFormattedTable

public JFormattedTable(Vector rowData,
                       Vector columnNames,
                       FieldModel fm)
Creates a new JFormattedTable with the specified data, column names and field model.

Parameters:
rowData - The data of the table.
columnNames - The names of each column.
fm - The default field model for formatting and validating.

JFormattedTable

public JFormattedTable(TableModel dm)
Creates new JFormattedTable with the specified TableModel.

Parameters:
dm - the data model for the table.

JFormattedTable

public JFormattedTable(TableModel dm,
                       FieldModel fm)
Creates a new JFormattedTable with the specified TableModel and FieldModel.

Parameters:
dm - The data model of the table.
fm - The default field model for formatting and validating.

JFormattedTable

public JFormattedTable(TableModel dm,
                       TableColumnModel cm)
Creates a new JFormattedTable with the specified TableModel and TableColumnModel.

Parameters:
dm - The data model for the table.
cm - The column model for the table.

JFormattedTable

public JFormattedTable(TableModel dm,
                       TableColumnModel cm,
                       ListSelectionModel sm)
Creates a new JFormattedTable with the specified TableModel,TableColumnModel and ListSelectionModel.

Parameters:
dm - The data model for the table.
cm - The column model for the table.
sm - The row selection model for the table.
Method Detail

Copyright

public static String Copyright()
Copyright notice.

Returns:
java.lang.String

createDefaultColumnsFromModel

public void createDefaultColumnsFromModel()
Creates default table columns from table model. The default table column is JFormattedTableColumn.

Overrides:
createDefaultColumnsFromModel in class JTable
See Also:
JFormattedTableColumn, JTable.createDefaultColumnsFromModel()

getFieldModel

public FieldModel getFieldModel()
Gets the default field model.

Specified by:
getFieldModel in interface JFormattedComponent
Returns:
com.ibm.etools.iseries.ui.FieldModel

isCellEditable

public boolean isCellEditable(int row,
                              int column)
Returns true if the cell at row and column is editable. If the table column with the specified column number is an instance of JFormattedTableColumn, JFormattedTable returns the cellEditable property of this column. Otherwise, JFormattedTable delegates the check to its TableModel.

Overrides:
isCellEditable in class JTable
Parameters:
row - The row number of the cell.
column - The column number of the cell.
See Also:
JFormattedTableColumn, JTable.isCellEditable(int, int)

isSelectionEmpty

public boolean isSelectionEmpty()
Returns true if nothing is selected.


setFieldModel

public void setFieldModel(FieldModel fm)
Sets the default field model of the JFormattedTable. This field model is used to specify the field model of the JFormattedTableColumn instances which are created from its data model.

Specified by:
setFieldModel in interface JFormattedComponent
Parameters:
fm - The default field model for formatting and validating.
See Also:
JFormattedComponent.getFieldModel()

setVisibleRowCount

public void setVisibleRowCount(int rows)
Sets how many rows to make visible at once.

Parameters:
rows - The preferred number of rows to display without using a scrollbar.

Rational Developer for Power Systems Software
V7.6

Copyright © 2011 IBM Corp. All Rights Reserved.

Note: This documentation is for part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.