|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.JTable edu.northwestern.at.utils.swing.XTable
public class XTable
A JTable with different defaults and behavior.
AddIcon
interface.The constructors are the same as in JTable. We did not bother giving them their own javadoc.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JTable |
---|
javax.swing.JTable.AccessibleJTable, javax.swing.JTable.DropLocation, javax.swing.JTable.PrintMode |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
javax.swing.JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
java.awt.Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
---|---|
protected boolean |
copyColumnHeaders
True to copy column headers along with data to clipboard. |
protected java.awt.Color |
evenRowColor
Even row color when striping enabled. |
protected java.awt.event.MouseListener |
mouseListener
Mouse listener interceptor. |
protected java.awt.Color |
oddRowColor
Odd row color when striping enabled. |
protected boolean |
stripeEmptyRows
True to striped "empty" rows after end of table rows proper. |
protected boolean |
stripeRows
True to enabled striping alternate rows in table. |
protected java.lang.String |
title
Table title. |
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 | |
---|---|
XTable()
Create extended table. |
|
XTable(int numRows,
int numColumns)
|
|
XTable(java.lang.Object[][] rowData,
java.lang.Object[] columnNames)
|
|
XTable(javax.swing.table.TableModel dm)
|
|
XTable(javax.swing.table.TableModel dm,
javax.swing.table.TableColumnModel cm)
|
|
XTable(javax.swing.table.TableModel dm,
javax.swing.table.TableColumnModel cm,
javax.swing.ListSelectionModel sm)
|
|
XTable(java.util.Vector rowData,
java.util.Vector columnNames)
|
Method Summary | |
---|---|
void |
copy()
Clipboard copy. |
void |
cut()
Clipboard cut. |
java.awt.Color |
getColorForRow(int row)
Get background color for a given row. |
javax.swing.Action |
getCopyAction()
Gets the copy action. |
boolean |
getCopyColumnHeaders()
Get status of copying column headers to clipboard. |
javax.swing.Action |
getPasteAction()
Gets the paste action. |
PrintableComponent |
getPrintableComponent(java.lang.String title,
java.awt.print.PageFormat pageFormat)
Return printable component. |
boolean |
getScrollableTracksViewportHeight()
Causes table to expand to fill all its available space. |
boolean |
getScrollableTracksViewportWidth()
Determines if horizontal scroll bar required. |
boolean |
getStriped()
Get striping status for the table. |
boolean |
getStripeEmptyRows()
Get empty row striping status for the table. |
java.lang.String |
getTitle()
Get the table title. |
void |
hideColumn(int columnNumber)
Hides a column by setting its width to zero. |
boolean |
isCopyEnabled()
Is copy enabled? |
boolean |
isCutEnabled()
Is cut enabled? |
boolean |
isPasteEnabled()
Is paste enabled? |
boolean |
isSelectAllEnabled()
Checks if "select all" enabled. |
boolean |
isTextSelected()
Is anything selected which can be cut/copied? |
boolean |
isUnselectEnabled()
Is unselect enabled? |
void |
paint(java.awt.Graphics graphics)
Paints empty table rows to support striped output. |
protected void |
paintEmptyRows(java.awt.Graphics graphics)
Paint background of implied empty rows when table rows do not fill the visible area. |
void |
paste()
Clipboard paste. |
java.awt.Component |
prepareRenderer(javax.swing.table.TableCellRenderer renderer,
int row,
int column)
Paint alternate rows in different colors. |
void |
printContents()
Prints the table. |
void |
printContents(java.lang.String title,
java.awt.print.PrinterJob printerJob,
java.awt.print.PageFormat pageFormat)
Prints the table. |
void |
saveToFile(java.lang.String fileName)
Save table data to a named file. |
void |
saveToFile(java.awt.Window parentWindow)
Save table data to a file using a file dialog. |
void |
setColumnRenderer(int columnNumber,
javax.swing.table.TableCellRenderer renderer)
Sets the table cell renderer for a column. |
void |
setColumnWidth(int columnNumber,
java.lang.Object longValue)
Sets the width of a column to accomodate a long value. |
void |
setColumnWidth(int columnNumber,
java.lang.Object longValue,
boolean setMaxSize)
Sets the width of a column to accomodate a long value. |
void |
setCopyColumnHeaders(boolean copyColumnHeaders)
Enable or disable copying column headers to clipboard. |
void |
setHeaderBackground(java.awt.Color backgroundColor)
Set header background color. |
void |
setHeaderForeground(java.awt.Color foregroundColor)
Set header foreground color. |
void |
setStripeColors(java.awt.Color evenRowColor,
java.awt.Color oddRowColor)
Set the stripe colors. |
void |
setStriped(boolean stripeRows)
Enable or disable striping for the table. |
void |
setStripeEmptyRows(boolean stripeEmptyRows)
Enable or disable empty row striping for the table. |
void |
setTitle(java.lang.String title)
Set the table title. |
void |
tableChanged(javax.swing.event.TableModelEvent e)
Handles a table changed event. |
void |
unselect()
Unselect selection. |
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, createDefaultColumnsFromModel, 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, getScrollableUnitIncrement, getSelectedColumn, getSelectedColumnCount, getSelectedColumns, getSelectedRow, getSelectedRowCount, getSelectedRows, getSelectionBackground, getSelectionForeground, getSelectionModel, getShowHorizontalLines, getShowVerticalLines, getSurrendersFocusOnKeystroke, getTableHeader, getToolTipText, getUI, getUIClassID, getUpdateSelectionOnSort, getValueAt, initializeLocalVars, isCellEditable, isCellSelected, isColumnSelected, isEditing, isRowSelected, moveColumn, paramString, prepareEditor, 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, 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, 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 |
Methods inherited from interface edu.northwestern.at.utils.swing.SelectAll |
---|
selectAll |
Field Detail |
---|
protected boolean stripeRows
protected boolean stripeEmptyRows
protected java.awt.Color evenRowColor
protected java.awt.Color oddRowColor
protected java.lang.String title
protected boolean copyColumnHeaders
protected java.awt.event.MouseListener mouseListener
Modifies the selection on clicked events rather than pressed events.
Constructor Detail |
---|
public XTable()
public XTable(int numRows, int numColumns)
public XTable(java.lang.Object[][] rowData, java.lang.Object[] columnNames)
public XTable(javax.swing.table.TableModel dm)
public XTable(javax.swing.table.TableModel dm, javax.swing.table.TableColumnModel cm)
public XTable(javax.swing.table.TableModel dm, javax.swing.table.TableColumnModel cm, javax.swing.ListSelectionModel sm)
public XTable(java.util.Vector rowData, java.util.Vector columnNames)
Method Detail |
---|
public void tableChanged(javax.swing.event.TableModelEvent e)
We override this method to fix a Swing bug: Newly inserted rows should not be selected.
tableChanged
in interface javax.swing.event.TableModelListener
tableChanged
in class javax.swing.JTable
e
- The table model event. public void setColumnRenderer(int columnNumber, javax.swing.table.TableCellRenderer renderer)
columnNumber
- Column number.renderer
- Renderer. public void setColumnWidth(int columnNumber, java.lang.Object longValue, boolean setMaxSize)
Both the preferred and the maximum width are set. This method is used to set the width of the setting name column.
columnNumber
- Column number.longValue
- The long value.setMaxSize
- Fix the column size to the long value's
size. public void setColumnWidth(int columnNumber, java.lang.Object longValue)
Both the preferred and the maximum width are set. This method is used to set the width of the setting name column.
columnNumber
- Column number.longValue
- The long value. public void hideColumn(int columnNumber)
columnNumber
- The column to hide. public void printContents(java.lang.String title, java.awt.print.PrinterJob printerJob, java.awt.print.PageFormat pageFormat)
title
- Title for output.printerJob
- The printer job.pageFormat
- The printer page format. public void printContents()
public PrintableComponent getPrintableComponent(java.lang.String title, java.awt.print.PageFormat pageFormat)
getPrintableComponent
in interface PrintableContents
title
- Title for printing.pageFormat
- Page format for printing.
public void cut()
cut
in interface CutCopyPaste
public void copy()
copy
in interface CutCopyPaste
public void paste()
paste
in interface CutCopyPaste
public javax.swing.Action getCopyAction()
public javax.swing.Action getPasteAction()
public boolean isCutEnabled()
isCutEnabled
in interface CutCopyPaste
public boolean isCopyEnabled()
isCopyEnabled
in interface CutCopyPaste
public boolean isPasteEnabled()
isPasteEnabled
in interface CutCopyPaste
public void paint(java.awt.Graphics graphics)
paint
in class javax.swing.JComponent
graphics
- The graphics object on which to display the table. protected void paintEmptyRows(java.awt.Graphics graphics)
graphics
- The graphics context for the table. public boolean getScrollableTracksViewportHeight()
getScrollableTracksViewportHeight
in interface javax.swing.Scrollable
getScrollableTracksViewportHeight
in class javax.swing.JTable
public boolean getScrollableTracksViewportWidth()
getScrollableTracksViewportWidth
in interface javax.swing.Scrollable
getScrollableTracksViewportWidth
in class javax.swing.JTable
public void setHeaderForeground(java.awt.Color foregroundColor)
foregroundColor
- The header foreground color. public void setHeaderBackground(java.awt.Color backgroundColor)
backgroundColor
- The header background color. public boolean getStriped()
public void setStriped(boolean stripeRows)
stripeRows
- true to enable alternate rows
to be striped, false to leave the
rows unstriped. public boolean getStripeEmptyRows()
public void setStripeEmptyRows(boolean stripeEmptyRows)
stripeEmptyRows
- true to enable striping empty rows
following the table rows proper. public void setStripeColors(java.awt.Color evenRowColor, java.awt.Color oddRowColor)
evenRowColor
- The color for even rows.oddRowColor
- The color for odd rows.
Selected rows are not striped.
public java.awt.Color getColorForRow(int row)
row
- The row.
public java.awt.Component prepareRenderer(javax.swing.table.TableCellRenderer renderer, int row, int column)
prepareRenderer
in class javax.swing.JTable
renderer
- The parent renderer.row
- The row for the cell to paint.column
- The column for the cell to paint. public boolean isTextSelected()
isTextSelected
in interface CutCopyPaste
public void setTitle(java.lang.String title)
title
- The table title.
The title is used for printing and file saving purposes.
public java.lang.String getTitle()
public void saveToFile(java.lang.String fileName)
saveToFile
in interface SaveToFile
fileName
- Name of file to which to save results. public void saveToFile(java.awt.Window parentWindow)
saveToFile
in interface SaveToFile
parentWindow
- Parent window for file dialog.
Runs a file dialog to get the name of the file to which to save results.
public void setCopyColumnHeaders(boolean copyColumnHeaders)
copyColumnHeaders
- true to copy column headers to clipboard. public boolean getCopyColumnHeaders()
public boolean isSelectAllEnabled()
isSelectAllEnabled
in interface SelectAll
public void unselect()
unselect
in interface SelectAll
public boolean isUnselectEnabled()
isUnselectEnabled
in interface SelectAll
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |