|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JTable
eu.beesoft.gaia.swing.JZebraTable
public class JZebraTable
Expands capabilities of javax.swing.JTable component.
JZebraTable has the following features:
createScrollPane(JZebraTable)
method instead of
new JScrollPane (table) to ensure the pretty look of the table
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JTable |
---|
javax.swing.JTable.AccessibleJTable, 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.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
---|---|
static java.awt.Color |
DEFAULT
|
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, dataModel, defaultEditorsByColumnClass, defaultRenderersByColumnClass, editingColumn, editingRow, editorComp, gridColor, preferredViewportSize, rowHeight, rowMargin, rowSelectionAllowed, selectionBackground, selectionForeground, selectionModel, 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 | |
---|---|
JZebraTable()
Create a new instance of the JZebraTable. |
Method Summary | |
---|---|
javax.swing.table.TableColumn |
addColumn(java.lang.String title)
Adds a new column with given title to the column model |
protected javax.swing.table.TableColumnModel |
createDefaultColumnModel()
Overriden to create and return internal column model. |
protected javax.swing.table.JTableHeader |
createDefaultTableHeader()
Creates the default table header object, which is a JTableHeader . |
static javax.swing.JScrollPane |
createScrollPane(JZebraTable table)
Creates instance of JScrollPane for given table and other
components to resolve JTable bug with AUTO_RESIZE_OFF. |
java.awt.Color |
getAlternateBackground()
Returns an alternate color. |
java.awt.Color |
getBackgroundForRow(int row)
Returns color used to paint background for given row . |
javax.swing.table.TableColumn |
getColumnByModelIndex(int modelColumnIndex)
Maps the index of the column in the table model at modelColumnIndex to the TableColumn object. |
int |
getColumnCount(boolean onlyVisible)
Returns the total number of columns in this model. |
int |
getColumnIndex(java.lang.Object identifier,
boolean onlyVisible)
Returns the position of the first column whose identifier equals identifier . |
java.util.List<javax.swing.table.TableColumn> |
getColumns(boolean onlyVisible)
Returns a list of all the columns in the model. |
java.awt.Color |
getDefaultAlternateBackground()
Returns default alternate color. |
boolean |
getScrollableTracksViewportHeight()
Force the table to fill the viewport's height. |
boolean |
getScrollableTracksViewportWidth()
Returns false to indicate that horizontal scrollbars are required to display the table while honoring perferred column widths. |
boolean |
getShowHorizontalLines()
Returns true if the table draws horizontal lines between cells, false if it doesn't. |
boolean |
getShowVerticalLines()
Returns true if the table draws vertical lines between cells, false if it doesn't. |
boolean |
isColumnVisible(javax.swing.table.TableColumn aColumn)
Checks wether the specified column is currently visible. |
void |
pack()
Packs table columns to their preferred sizes. |
void |
packColumn(int columnIndex)
Packs the table column with given columnIndex to its
preferred size. |
void |
paintComponent(java.awt.Graphics g)
Add stripes between cells and behind non-opaque cells. |
java.awt.Component |
prepareEditor(javax.swing.table.TableCellEditor editor,
int row,
int col)
Add background stripes behind edited cells. |
java.awt.Component |
prepareRenderer(javax.swing.table.TableCellRenderer renderer,
int row,
int col)
Add background stripes behind rendered cells. |
void |
setAllColumnsVisible()
Makes all columns in this model visible |
void |
setAlternateBackground(java.awt.Color alternateBackground)
Sets a new value to alternate color. |
void |
setColumnModel(javax.swing.table.TableColumnModel model)
This method prevents to set other column model than that one created internally by this instance. |
void |
setColumnVisible(javax.swing.table.TableColumn column,
boolean visible)
Sets the visibility of the specified TableColumn. |
void |
setShowGrid(boolean showGrid)
Sets whether the table draws grid lines around cells. |
void |
setShowHorizontalLines(boolean showHorizontalLines)
Sets whether the table draws horizontal lines between cells. |
void |
setShowVerticalLines(boolean showVerticalLines)
Sets whether the table draws vertical lines between cells. |
void |
setVisibleRowCount(int rows)
Sets visible row count for the table. |
Methods inherited from class javax.swing.JTable |
---|
addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, clearSelection, columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, configureEnclosingScrollPane, convertColumnIndexToModel, convertColumnIndexToView, createDefaultColumnsFromModel, createDefaultDataModel, createDefaultEditors, createDefaultRenderers, createDefaultSelectionModel, createScrollPaneForTable, doLayout, editCellAt, editCellAt, editingCanceled, editingStopped, getAccessibleContext, getAutoCreateColumnsFromModel, getAutoResizeMode, getCellEditor, getCellEditor, getCellRect, getCellRenderer, getCellSelectionEnabled, getColumn, getColumnClass, getColumnCount, getColumnModel, getColumnName, getColumnSelectionAllowed, getDefaultEditor, getDefaultRenderer, getDragEnabled, getEditingColumn, getEditingRow, getEditorComponent, getGridColor, getIntercellSpacing, getModel, getPreferredScrollableViewportSize, getPrintable, getRowCount, getRowHeight, getRowHeight, getRowMargin, getRowSelectionAllowed, getScrollableBlockIncrement, getScrollableUnitIncrement, getSelectedColumn, getSelectedColumnCount, getSelectedColumns, getSelectedRow, getSelectedRowCount, getSelectedRows, getSelectionBackground, getSelectionForeground, getSelectionModel, getSurrendersFocusOnKeystroke, getTableHeader, getToolTipText, getUI, getUIClassID, getValueAt, changeSelection, initializeLocalVars, isCellEditable, isCellSelected, isColumnSelected, isEditing, isRowSelected, moveColumn, paramString, print, print, print, print, processKeyBinding, removeColumn, removeColumnSelectionInterval, removeEditor, removeNotify, removeRowSelectionInterval, resizeAndRepaint, rowAtPoint, selectAll, setAutoCreateColumnsFromModel, setAutoResizeMode, setCellEditor, setCellSelectionEnabled, setColumnSelectionAllowed, setColumnSelectionInterval, setDefaultEditor, setDefaultRenderer, setDragEnabled, setEditingColumn, setEditingRow, setGridColor, setIntercellSpacing, setModel, setPreferredScrollableViewportSize, setRowHeight, setRowHeight, setRowMargin, setRowSelectionAllowed, setRowSelectionInterval, setSelectionBackground, setSelectionForeground, setSelectionMode, setSelectionModel, setSurrendersFocusOnKeystroke, setTableHeader, setUI, setValueAt, sizeColumnsToFit, sizeColumnsToFit, 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, 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, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printComponent, printChildren, 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, 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, checkImage, checkImage, 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 |
---|
public static java.awt.Color DEFAULT
Constructor Detail |
---|
public JZebraTable()
Method Detail |
---|
protected javax.swing.table.JTableHeader createDefaultTableHeader()
JTableHeader
. A subclass can override this method to return
a different table header object.
createDefaultTableHeader
in class javax.swing.JTable
public java.awt.Color getAlternateBackground()
public void setAlternateBackground(java.awt.Color alternateBackground)
alternateBackground
- - alternate color to setpublic java.awt.Color getDefaultAlternateBackground()
public boolean getShowHorizontalLines()
getShowHorizontalLines
in class javax.swing.JTable
public void setShowHorizontalLines(boolean showHorizontalLines)
setShowHorizontalLines
in class javax.swing.JTable
showHorizontalLines
- - a new value to setpublic boolean getShowVerticalLines()
getShowVerticalLines
in class javax.swing.JTable
public void setShowVerticalLines(boolean showVerticalLines)
setShowVerticalLines
in class javax.swing.JTable
showVerticalLines
- - a new value to setpublic void setShowGrid(boolean showGrid)
setShowHorizontalLines(boolean)
and
setShowVerticalLines(boolean)
.
setShowGrid
in class javax.swing.JTable
showGrid
- - a new value to setpublic void setVisibleRowCount(int rows)
rows
- - a number of visible rowspublic void paintComponent(java.awt.Graphics g)
paintComponent
in class javax.swing.JComponent
g
- - the graphics context to use for paintingpublic java.awt.Component prepareRenderer(javax.swing.table.TableCellRenderer renderer, int row, int col)
prepareRenderer
in class javax.swing.JTable
public java.awt.Component prepareEditor(javax.swing.table.TableCellEditor editor, int row, int col)
prepareEditor
in class javax.swing.JTable
public java.awt.Color getBackgroundForRow(int row)
row
.
row
- - a row number
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 pack()
public void packColumn(int columnIndex)
columnIndex
to its
preferred size. Asks every cell on the column for its preferred size and
takes the maximum value.
columnIndex
- - index of column to be packedpublic void setColumnModel(javax.swing.table.TableColumnModel model)
setColumnModel
in class javax.swing.JTable
model
- - column model to setprotected final javax.swing.table.TableColumnModel createDefaultColumnModel()
createDefaultColumnModel
in class javax.swing.JTable
public javax.swing.table.TableColumn addColumn(java.lang.String title)
title
to the column model
title
- - title (name or label) for column
public void setColumnVisible(javax.swing.table.TableColumn column, boolean visible)
column
- -
the column to show/hidevisible
- -
its new visibility statuspublic void setAllColumnsVisible()
public javax.swing.table.TableColumn getColumnByModelIndex(int modelColumnIndex)
modelColumnIndex
to the TableColumn object. There may me
multiple TableColumn objects showing the same model column, though this
is uncommon. This method will always return the first visible or else the
first invisible column with the specified index.
modelColumnIndex
- index of column in table model
public boolean isColumnVisible(javax.swing.table.TableColumn aColumn)
aColumn
- column to check
public int getColumnCount(boolean onlyVisible)
onlyVisible
- - if set, only visible columns will be counted
tableColumns
arraypublic java.util.List<javax.swing.table.TableColumn> getColumns(boolean onlyVisible)
onlyVisible
- if set, all invisible columns will be missing from the
returned list
public int getColumnIndex(java.lang.Object identifier, boolean onlyVisible)
identifier
. Position is the the index in all visible columns
if onlyVisible
is true or else the index in all columns.
identifier
- the identifier object to search foronlyVisible
- if set searches only visible columns
identifier
java.lang.IllegalArgumentException
- if identifier
is null
, or if no
TableColumn
has this identifier
public static javax.swing.JScrollPane createScrollPane(JZebraTable table)
table
and other
components to resolve JTable bug with AUTO_RESIZE_OFF.
table
- - the table to be wrapped by scrollpane
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |