|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--javax.swing.JComponent | +--javax.swing.JTable | +--com.zfqjava.swing.JDataGrid
JDataGrid
provides a data grid, add some features
such as row header, cell attributes, cell merge and split,
undo and redo support.
The DataGridModel
provides model support for cell attributes,
cell class, cell editable, undo support, cell merge and split and other
set methods for column name and column class. It's TableModel subclass.
The ObjectCellRenderer
provides the
basic cell renderer for render cell attributes.
The ObjectCellEditor
provides the
basic cell editor.
JDataGrid provides a row header when add into JScrollPane
container, and build-in Date
, Number
and
Boolean
and String
and Multiple line
String
renderer and editor to support cell attributes and other
features.
Note:
Since JDataGrid
is compitable with JTable
at API level, use it just replace JTable
with JDataGrid
.
Inner Class Summary | |
protected class |
JDataGrid.AccessibleJDataGrid
This class implements accessibility support for the JDataGrid class. |
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 |
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 | |
JDataGrid()
Constructs a default JDataGrid that is initialized with a default
data model, a default column model, and a default selection
model. |
|
JDataGrid(int numRows,
int numColumns)
Constructs a JDataGrid with numRows
and numColumns of empty cells using
DefaultTableModel . |
|
JDataGrid(java.lang.Object[][] rowData,
java.lang.Object[] columnNames)
Constructs a JDataGrid to display the values in the two dimensional array,
rowData , with column names, columnNames . |
|
JDataGrid(javax.swing.table.TableModel dm)
Constructs a JDataGrid that is initialized with
dm as the data model, a default column model,
and a default selection model. |
|
JDataGrid(javax.swing.table.TableModel dm,
javax.swing.table.TableColumnModel cm)
Constructs a JDataGrid that is initialized with
dm as the data model, cm
as the column model, and a default selection model. |
|
JDataGrid(javax.swing.table.TableModel dm,
javax.swing.table.TableColumnModel cm,
javax.swing.ListSelectionModel sm)
Constructs a JDataGrid that is initialized with
dm as the data model, cm as the
column model, and sm as the selection model. |
|
JDataGrid(java.util.Vector rowData,
java.util.Vector columnNames)
Constructs a JDataGrid to display the values in the
Vector of Vectors , rowData ,
with column names, columnNames . |
Method Summary | |
void |
addColumn(javax.swing.table.TableColumn aColumn)
|
void |
addUndoableEditListener(javax.swing.event.UndoableEditListener l)
Registers the given observer to begin receiving notifications when undoable edits are made to the data grid. |
void |
cellChanged(DataGridModelEvent e)
Invoked when this dataGrid's DataGridModel generates
a DataGridModelEvent . |
void |
clearSelection()
|
void |
columnSelectionChanged(javax.swing.event.ListSelectionEvent e)
|
protected void |
configureEnclosingScrollPane()
|
protected void |
createDefaultEditors()
|
protected void |
createDefaultRenderers()
|
protected javax.swing.table.JTableHeader |
createDefaultTableHeader()
|
boolean |
editCellAt(int row,
int column,
java.util.EventObject e)
|
protected void |
fireUndoableEditHappened(javax.swing.undo.UndoableEdit edit)
Notifies all listeners that have registered interest for notification on this event type. |
javax.accessibility.AccessibleContext |
getAccessibleContext()
Gets the AccessibleContext associated with this JDataGrid. |
javax.swing.table.TableCellEditor |
getCellEditor(int row,
int column)
|
java.awt.Rectangle |
getCellRect(Cell c,
boolean includeSpacing)
Returns a rectangle for the cell that lies at the intersection of c . |
javax.swing.table.TableCellRenderer |
getCellRenderer(int row,
int column)
|
javax.swing.table.TableCellEditor |
getDefaultEditor(java.lang.Class columnClass)
|
javax.swing.table.TableCellRenderer |
getDefaultRenderer(java.lang.Class columnClass)
|
JLineBar |
getRowHeader()
Returns the row header for this table. |
Cell |
getSelectedCell()
Returns the selected cell as Cell object. |
Cell[] |
getSelectedCells()
Returns all selected cells. |
java.lang.String |
getUIClassID()
Returns a string that specifies the name of the L&F class that renders this component. |
javax.swing.event.UndoableEditListener[] |
getUndoableEditListeners()
Returns an array of all the undoable edit listeners registered on this data grid. |
protected void |
initializeLocalVars()
|
boolean |
isCellSelected(int row,
int column)
|
boolean |
isColumnSelected(int column)
|
boolean |
isRowSelected(int row)
|
protected java.lang.String |
paramString()
Returns a string representation of this JDataGrid. |
java.awt.Component |
prepareEditor(javax.swing.table.TableCellEditor editor,
int row,
int column)
|
java.awt.Component |
prepareRenderer(javax.swing.table.TableCellRenderer renderer,
int row,
int column)
|
void |
removeColumn(javax.swing.table.TableColumn aColumn)
|
void |
removeEditor()
|
void |
removeUndoableEditListener(javax.swing.event.UndoableEditListener l)
Unregisters the given observer from the notification list so it will no longer receive updates. |
void |
selectCell(Cell c)
Selects the specified cell in the data grid. |
void |
selectCell(int row,
int column)
Selects the specified cell in the data grid. |
void |
selectCell(int firstRow,
int lastRow,
int firstColumn,
int lastColumn)
Selects the specified cell in the data grid. |
void |
selectColumn(int column)
Selects the specified column in the data grid. |
void |
selectRow(int row)
Selects the specified row in the data grid. |
void |
setModel(javax.swing.table.TableModel dataModel)
|
void |
setRowHeader(JLineBar rowHeader)
Sets the row header for this table. |
void |
setRowHeight(int row,
int rowHeight)
|
void |
tableChanged(javax.swing.event.TableModelEvent e)
|
protected void |
unconfigureEnclosingScrollPane()
|
void |
undoableEditHappened(javax.swing.event.UndoableEditEvent e)
An undoable edit happened |
void |
updateUI()
Resets the UI property with a value from the current look and feel. |
void |
valueChanged(javax.swing.event.ListSelectionEvent e)
|
Methods inherited from class javax.swing.JTable |
addColumnSelectionInterval, addNotify, addRowSelectionInterval, changeSelection, columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, convertColumnIndexToModel, convertColumnIndexToView, createDefaultColumnModel, createDefaultColumnsFromModel, createDefaultDataModel, createDefaultSelectionModel, createScrollPaneForTable, doLayout, editCellAt, editingCanceled, editingStopped, getAutoCreateColumnsFromModel, getAutoResizeMode, getCellEditor, getCellRect, getCellSelectionEnabled, getColumn, getColumnClass, getColumnCount, getColumnModel, getColumnName, getColumnSelectionAllowed, 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, getValueAt, isCellEditable, isEditing, isFocusTraversable, isManagingFocus, moveColumn, processKeyBinding, removeColumnSelectionInterval, removeNotify, removeRowSelectionInterval, resizeAndRepaint, rowAtPoint, selectAll, setAutoCreateColumnsFromModel, setAutoResizeMode, setCellEditor, setCellSelectionEnabled, setColumnModel, setColumnSelectionAllowed, setColumnSelectionInterval, setDefaultEditor, setDefaultRenderer, setEditingColumn, setEditingRow, setGridColor, setIntercellSpacing, setPreferredScrollableViewportSize, setRowHeight, setRowMargin, setRowSelectionAllowed, setRowSelectionInterval, setSelectionBackground, setSelectionForeground, setSelectionMode, setSelectionModel, setShowGrid, setShowHorizontalLines, setShowVerticalLines, setTableHeader, setUI, setValueAt, sizeColumnsToFit, sizeColumnsToFit |
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 |
Constructor Detail |
public JDataGrid()
JDataGrid
that is initialized with a default
data model, a default column model, and a default selection
model.JTable.createDefaultDataModel()
,
JTable.createDefaultColumnModel()
,
JTable.createDefaultSelectionModel()
public JDataGrid(javax.swing.table.TableModel dm)
JDataGrid
that is initialized with
dm
as the data model, a default column model,
and a default selection model.dm
- the data model for the tableJTable.createDefaultColumnModel()
,
JTable.createDefaultSelectionModel()
public JDataGrid(javax.swing.table.TableModel dm, javax.swing.table.TableColumnModel cm)
JDataGrid
that is initialized with
dm
as the data model, cm
as the column model, and a default selection model.dm
- the data model for the tablecm
- the column model for the tableJTable.createDefaultSelectionModel()
public JDataGrid(javax.swing.table.TableModel dm, javax.swing.table.TableColumnModel cm, javax.swing.ListSelectionModel sm)
JDataGrid
that is initialized with
dm
as the data model, cm
as the
column model, and sm
as the selection model.
If any of the parameters are null
this method
will initialize the table with the corresponding default model.
The autoCreateColumnsFromModel
flag is set to false
if cm
is non-null, otherwise it is set to true
and the column model is populated with suitable
TableColumns
for the columns in dm
.dm
- the data model for the tablecm
- the column model for the tablesm
- the row selection model for the tableJTable.createDefaultDataModel()
,
JTable.createDefaultColumnModel()
,
JTable.createDefaultSelectionModel()
public JDataGrid(int numRows, int numColumns)
JDataGrid
with numRows
and numColumns
of empty cells using
DefaultTableModel
. The columns will have
names of the form "A", "B", "C", etc.numRows
- the number of rows the table holdsnumColumns
- the number of columns the table holdsDefaultTableModel
public JDataGrid(java.util.Vector rowData, java.util.Vector columnNames)
JDataGrid
to display the values in the
Vector
of Vectors
, rowData
,
with column names, columnNames
. The
Vectors
contained in rowData
should contain the values for that row. In other words,
the value of the cell at row 1, column 5 can be obtained
with the following code:
((Vector)rowData.elementAt(1)).elementAt(5);
rowData
- the data for the new tablecolumnNames
- names of each columnpublic JDataGrid(java.lang.Object[][] rowData, java.lang.Object[] columnNames)
JDataGrid
to display the values in the two dimensional array,
rowData
, with column names, columnNames
.
rowData
is an array of rows, so the value of the cell at row 1,
column 5 can be obtained with the following code:
rowData[1][5];
All rows must be of the same length as columnNames
.
rowData
- the data for the new tablecolumnNames
- names of each columnMethod Detail |
public void updateUI()
updateUI
in class javax.swing.JTable
JComponent.updateUI()
public java.lang.String getUIClassID()
getUIClassID
in class javax.swing.JTable
JComponent.getUIClassID()
,
UIDefaults.getUI(javax.swing.JComponent)
protected void initializeLocalVars()
initializeLocalVars
in class javax.swing.JTable
protected void configureEnclosingScrollPane()
configureEnclosingScrollPane
in class javax.swing.JTable
protected void unconfigureEnclosingScrollPane()
unconfigureEnclosingScrollPane
in class javax.swing.JTable
public void setRowHeight(int row, int rowHeight)
setRowHeight
in class javax.swing.JTable
public void addColumn(javax.swing.table.TableColumn aColumn)
addColumn
in class javax.swing.JTable
public void removeColumn(javax.swing.table.TableColumn aColumn)
removeColumn
in class javax.swing.JTable
protected javax.swing.table.JTableHeader createDefaultTableHeader()
createDefaultTableHeader
in class javax.swing.JTable
protected void createDefaultRenderers()
createDefaultRenderers
in class javax.swing.JTable
protected void createDefaultEditors()
createDefaultEditors
in class javax.swing.JTable
public javax.swing.table.TableCellRenderer getDefaultRenderer(java.lang.Class columnClass)
getDefaultRenderer
in class javax.swing.JTable
public javax.swing.table.TableCellEditor getDefaultEditor(java.lang.Class columnClass)
getDefaultEditor
in class javax.swing.JTable
public javax.swing.table.TableCellRenderer getCellRenderer(int row, int column)
getCellRenderer
in class javax.swing.JTable
public java.awt.Component prepareRenderer(javax.swing.table.TableCellRenderer renderer, int row, int column)
prepareRenderer
in class javax.swing.JTable
public javax.swing.table.TableCellEditor getCellEditor(int row, int column)
getCellEditor
in class javax.swing.JTable
public java.awt.Component prepareEditor(javax.swing.table.TableCellEditor editor, int row, int column)
prepareEditor
in class javax.swing.JTable
public boolean editCellAt(int row, int column, java.util.EventObject e)
editCellAt
in class javax.swing.JTable
public void removeEditor()
removeEditor
in class javax.swing.JTable
public void clearSelection()
clearSelection
in class javax.swing.JTable
public boolean isRowSelected(int row)
isRowSelected
in class javax.swing.JTable
public boolean isColumnSelected(int column)
isColumnSelected
in class javax.swing.JTable
public boolean isCellSelected(int row, int column)
isCellSelected
in class javax.swing.JTable
public void setModel(javax.swing.table.TableModel dataModel)
setModel
in class javax.swing.JTable
public void tableChanged(javax.swing.event.TableModelEvent e)
tableChanged
in class javax.swing.JTable
public void columnSelectionChanged(javax.swing.event.ListSelectionEvent e)
columnSelectionChanged
in class javax.swing.JTable
public void valueChanged(javax.swing.event.ListSelectionEvent e)
valueChanged
in class javax.swing.JTable
public Cell getSelectedCell()
Cell
object.
Returns null if have not such selected cell or the selected cell
is not contiguous.Cell
objectpublic Cell[] getSelectedCells()
Cell
objectpublic java.awt.Rectangle getCellRect(Cell c, boolean includeSpacing)
c
.
If includeSpacing
is true then the value returned
has the full height and width of the row and column
specified. If it is false, the returned rectangle is inset by the
intercell spacing to return the true bounds of the rendering or
editing component as it will be set during rendering.c
- the cell areaincludeSpacing
- if false, return the true cell bounds -
computed by subtracting the intercell
spacing from the height and widths of
the column and row modelsc
public void setRowHeader(JLineBar rowHeader)
rowHeader
- the row headergetRowHeader()
public JLineBar getRowHeader()
setRowHeader(com.zfqjava.swing.JLineBar)
public void selectRow(int row)
row
- the specified rowpublic void selectColumn(int column)
column
- the specified columnpublic void selectCell(int row, int column)
row
- the row indexcolumn
- the column indexselectCell(int,int,int,int)
,
selectCell(Cell)
public void selectCell(int firstRow, int lastRow, int firstColumn, int lastColumn)
firstRow
- the first row index of the specified cell arealastRow
- the last row index of the specified cell areafirstColumn
- the first column index of the specified cell arealastColumn
- the last column index of the specified cell areaselectCell(int,int)
,
selectCell(Cell)
public void selectCell(Cell c)
c
- the specified cellselectCell(int,int)
,
selectCell(int,int,int,int)
public void cellChanged(DataGridModelEvent e)
DataGridModel
generates
a DataGridModelEvent
.
Application code will not use these methods explicitly, they
are used internally by JDataGrid
.
cellChanged
in interface DataGridModelListener
e
- the eventpublic void undoableEditHappened(javax.swing.event.UndoableEditEvent e)
Application code will not use these methods explicitly, they
are used internally by JDataGrid
.
undoableEditHappened
in interface javax.swing.event.UndoableEditListener
e
- the undoable editprotected void fireUndoableEditHappened(javax.swing.undo.UndoableEdit edit)
Application code will not use these methods explicitly, they
are used internally by JDataGrid
.
EventListenerList
public void addUndoableEditListener(javax.swing.event.UndoableEditListener l)
listener
- the observer to registerUndoableEditEvent
public void removeUndoableEditListener(javax.swing.event.UndoableEditListener l)
listener
- the observer to registerUndoableEditEvent
public javax.swing.event.UndoableEditListener[] getUndoableEditListeners()
UndoableEditListener
s
or an empty array if no undoable edit listeners are
currently registeredaddUndoableEditListener(javax.swing.event.UndoableEditListener)
,
removeUndoableEditListener(javax.swing.event.UndoableEditListener)
protected java.lang.String paramString()
null
.paramString
in class javax.swing.JTable
public javax.accessibility.AccessibleContext getAccessibleContext()
getAccessibleContext
in class javax.swing.JTable
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |