com.jstatcom.table
Class BorderTable
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JTable
-
- com.jstatcom.table.BorderTable
-
- All Implemented Interfaces:
- java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.CellEditorListener, javax.swing.event.ListSelectionListener, javax.swing.event.RowSorterListener, javax.swing.event.TableColumnModelListener, javax.swing.event.TableModelListener, javax.swing.Scrollable
- Direct Known Subclasses:
- JSCAbstractDataTable
public class BorderTable extends javax.swing.JTableA subclass ofJTablesthat respects the border set.JTablesdo not respect borders at all.Beside respecting borders this table can also deal with dynamic column width, e.g. it is possible to configure a
BorderTableobject such that it automatically adjustes the column width when the data displayed changes. These adjustments can be limited to a minimum and maximum width.This table draws grid lines before the first row and the first column. For that it needs 1 pixel each direction.
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JTable
javax.swing.JTable.DropLocation, javax.swing.JTable.PrintMode
-
-
Field Summary
-
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
-
-
Constructor Summary
Constructors Constructor and Description BorderTable()Constructs an emptyBorderTable.BorderTable(javax.swing.table.TableModel dm, javax.swing.table.TableColumnModel cm, javax.swing.ListSelectionModel sm)Constructs aBorderTablewith some default settings and initializes the border.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description intcolumnAtPoint(java.awt.Point point)Reimplements super method such that it considers the border now.voidcreateDefaultColumnsFromModel()Reimplements super method.java.awt.RectanglegetCellRect(int row, int column, boolean includeSpacing)Reimplements super method such that it considers the border now.intgetColumnWidth()Returns current column width.intgetMaximumColumnWidth()Returns maximum column width property.java.awt.DimensiongetMaximumSize()Returns the value of agetPreferredSize()method call.intgetMinimumColumnWidth()Returns minimum column width property.java.awt.DimensiongetMinimumSize()Returns the value of agetPreferredSize()method call.java.awt.DimensiongetPreferredSize()Reimplements super method such that it considers the border now.booleanisDynamicColumnWidth()Return true if theBorderTable's column width (and theBorderTable's width) depends on the data displayed.intmaxCellLength()Computes the maximum length of all cells.introwAtPoint(java.awt.Point point)Reimplements super method such that it considers the border now.voidsetBorder(javax.swing.border.Border border)Reimplements super method such that theborderTableBorderis always set as the most inner border.voidsetColumnWidth(int newValue)This method sets the column width of theBorderTabletonewValue.voidsetDynamicColumnWidth(boolean newDynamicColumnWidth)Set whether theBorderTable's column width adjust when the data displayed.voidsetIntercellSpacing(java.awt.Dimension newSpacing)Sets the width and height between cells tonewSpacingand redisplays the receiver.voidsetMaximumColumnWidth(int newMaximumColumnWidth)Sets theBorderTable's maximum column width.voidsetMinimumColumnWidth(int newMinimumColumnWidth)Sets theBorderTable's minimum column width.voidsizeColumnsToFit(int c)Empty method.voidtableChanged(javax.swing.event.TableModelEvent e)Calls super method and determines and sets new maximum column width ifisDynamicColumnWidthreturnstrue.-
Methods inherited from class javax.swing.JTable
addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, changeSelection, clearSelection, columnAdded, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, convertColumnIndexToModel, convertColumnIndexToView, convertRowIndexToModel, convertRowIndexToView, createScrollPaneForTable, doLayout, editCellAt, editCellAt, editingCanceled, editingStopped, getAccessibleContext, getAutoCreateColumnsFromModel, getAutoCreateRowSorter, getAutoResizeMode, getCellEditor, getCellEditor, 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, isCellEditable, isCellSelected, isColumnSelected, isEditing, isRowSelected, moveColumn, prepareEditor, prepareRenderer, print, print, print, print, print, removeColumn, removeColumnSelectionInterval, removeEditor, removeNotify, removeRowSelectionInterval, selectAll, setAutoCreateColumnsFromModel, setAutoCreateRowSorter, setAutoResizeMode, setCellEditor, setCellSelectionEnabled, setColumnModel, setColumnSelectionAllowed, setColumnSelectionInterval, setDefaultEditor, setDefaultRenderer, setDragEnabled, setDropMode, setEditingColumn, setEditingRow, setFillsViewportHeight, setGridColor, setModel, setPreferredScrollableViewportSize, setRowHeight, setRowHeight, setRowMargin, setRowSelectionAllowed, setRowSelectionInterval, setRowSorter, setSelectionBackground, setSelectionForeground, setSelectionMode, setSelectionModel, setShowGrid, setShowHorizontalLines, setShowVerticalLines, setSurrendersFocusOnKeystroke, setTableHeader, setUI, setUpdateSelectionOnSort, setValueAt, sizeColumnsToFit, sorterChanged, updateUI, valueChanged
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, 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, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, 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, 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, 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, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Constructor Detail
-
BorderTable
public BorderTable()
Constructs an emptyBorderTable.
-
BorderTable
public BorderTable(javax.swing.table.TableModel dm, javax.swing.table.TableColumnModel cm, javax.swing.ListSelectionModel sm)Constructs aBorderTablewith some default settings and initializes the border.- Parameters:
dm- the table modelcm- the column modelsm- the list selection model
-
-
Method Detail
-
columnAtPoint
public int columnAtPoint(java.awt.Point point)
Reimplements super method such that it considers the border now.- Overrides:
columnAtPointin classjavax.swing.JTable- Parameters:
point- the point to be checked for the underlying column- Returns:
- index of the respective column
-
createDefaultColumnsFromModel
public void createDefaultColumnsFromModel()
Reimplements super method. It regards possible individual column width now.- Overrides:
createDefaultColumnsFromModelin classjavax.swing.JTable
-
getCellRect
public java.awt.Rectangle getCellRect(int row, int column, boolean includeSpacing)Reimplements super method such that it considers the border now.- Overrides:
getCellRectin classjavax.swing.JTable
-
getColumnWidth
public int getColumnWidth()
Returns current column width. The width is not computed when calling this method.- Returns:
- int Current column width.
-
getMaximumColumnWidth
public int getMaximumColumnWidth()
Returns maximum column width property.- Returns:
- int maximum column width
-
getMaximumSize
public java.awt.Dimension getMaximumSize()
Returns the value of agetPreferredSize()method call.- Overrides:
getMaximumSizein classjavax.swing.JComponent
-
getMinimumColumnWidth
public int getMinimumColumnWidth()
Returns minimum column width property.- Returns:
- int minimum column width property
-
getMinimumSize
public java.awt.Dimension getMinimumSize()
Returns the value of agetPreferredSize()method call.- Overrides:
getMinimumSizein classjavax.swing.JComponent
-
getPreferredSize
public java.awt.Dimension getPreferredSize()
Reimplements super method such that it considers the border now.- Overrides:
getPreferredSizein classjavax.swing.JComponent
-
isDynamicColumnWidth
public boolean isDynamicColumnWidth()
Return true if theBorderTable's column width (and theBorderTable's width) depends on the data displayed.- Returns:
trueif dynamic adjustment is on
-
maxCellLength
public int maxCellLength()
Computes the maximum length of all cells. This means that this method evaluates the whole data model. This can be time consuming.
-
rowAtPoint
public int rowAtPoint(java.awt.Point point)
Reimplements super method such that it considers the border now.- Overrides:
rowAtPointin classjavax.swing.JTable- Parameters:
point- the point to be checked for the underlying row- Returns:
- index of the respective row
-
setBorder
public void setBorder(javax.swing.border.Border border)
Reimplements super method such that theborderTableBorderis always set as the most inner border.- Overrides:
setBorderin classjavax.swing.JComponent
-
setColumnWidth
public void setColumnWidth(int newValue)
This method sets the column width of theBorderTabletonewValue. IfnewValueexceeds the minimum or maximum width, it's adjusted to the appropriate limiting value. Posts a vetoable property change notification with the name"columnWidth".- Parameters:
newValue- the new column width- Throws:
java.lang.IllegalArgumentException-newValue < 0
-
setDynamicColumnWidth
public void setDynamicColumnWidth(boolean newDynamicColumnWidth)
Set whether theBorderTable's column width adjust when the data displayed. change. The adjustment takes place within the minimum and maximum width.- Parameters:
newDynamicColumnWidth- boolean
-
setIntercellSpacing
public void setIntercellSpacing(java.awt.Dimension newSpacing)
Sets the width and height between cells tonewSpacingand redisplays the receiver. Posts a vetoable property change notification with the name "intercellSpacing".- Overrides:
setIntercellSpacingin classjavax.swing.JTable- Parameters:
newSpacing- the new width and height intercellSpacing- See Also:
JTable.getIntercellSpacing()
-
setMaximumColumnWidth
public void setMaximumColumnWidth(int newMaximumColumnWidth)
Sets theBorderTable's maximum column width.- Parameters:
newMaximumColumnWidth- the new maximum width
-
setMinimumColumnWidth
public void setMinimumColumnWidth(int newMinimumColumnWidth)
Sets theBorderTable's minimum column width.- Parameters:
newMinimumColumnWidth- the new minimum width
-
sizeColumnsToFit
public final void sizeColumnsToFit(int c)
Empty method. Since sizing ofBorderTablesis determinied by the column width there is no need to fit the columns to set bounds.- Overrides:
sizeColumnsToFitin classjavax.swing.JTable
-
tableChanged
public void tableChanged(javax.swing.event.TableModelEvent e)
Calls super method and determines and sets new maximum column width ifisDynamicColumnWidthreturnstrue.- Specified by:
tableChangedin interfacejavax.swing.event.TableModelListener- Overrides:
tableChangedin classjavax.swing.JTable- Parameters:
e- the event
-
-
DMelt 3.0 © DataMelt by jWork.ORG