public class ResizeableTableHeader
extends javax.swing.table.JTableHeader
implements javax.swing.event.TableModelListener
JTableHeader
extends a JTable
with the ability to resize a column to fit all its content on double click
on the right end of the column's header cell.
javax.swing.table.JTableHeader.AccessibleJTableHeader
javax.swing.JComponent.AccessibleJComponent
Modifier and Type | Field and Description |
---|---|
protected boolean |
autoResizingEnabled
If true, auto resizing of columns when
the TableModel invokes a tableChanged event
is enabled.
|
protected boolean |
includeHeaderWidth
If true, resizing of columns will
also take the width of header cells
into account.
|
columnModel, draggedColumn, draggedDistance, reorderingAllowed, resizingAllowed, resizingColumn, table, updateTableInRealTime
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
ResizeableTableHeader()
Constructs a
ResizeableTableHeader with a default
TableColumnModel . |
ResizeableTableHeader(javax.swing.table.TableColumnModel cm)
Constructs a
ResizeableTableHeader which is initialized with
cm as the column model. |
Modifier and Type | Method and Description |
---|---|
boolean |
getAutoResizingEnabled()
Returns true if auto resizing is enabled.
|
boolean |
getIncludeHeaderWidth()
Returns true, if the header's width are
|
void |
resizeAllColumns()
Resizes all columns to fit all their content.
|
void |
resizeColumn(javax.swing.table.TableColumn column)
Resizes the given column to fit all its content.
|
void |
setAllColumnWidths(int preferredWidth,
int minWidth,
int maxWidth)
Sets preferred width, the minimum and maximum width for all columns.
|
void |
setAutoResizingEnabled(boolean autoResizingEnabled)
Sets whether columns are resized on table model events.
|
void |
setColumnWidths(javax.swing.table.TableColumn column,
int preferredWidth,
int minWidth,
int maxWidth)
Sets preferred width, the minimum and maximum width for a given column.
|
void |
setIncludeHeaderWidth(boolean includeHeaderWidth)
Sets whether the header's width are included on calculation
|
void |
setTable(javax.swing.JTable table)
Sets the table associated with this header.
|
void |
tableChanged(javax.swing.event.TableModelEvent e)
Listen for table model events from tablemodel.
|
columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, createDefaultColumnModel, createDefaultRenderer, getAccessibleContext, getColumnModel, getDefaultRenderer, getDraggedColumn, getDraggedDistance, getHeaderRect, getReorderingAllowed, getResizingAllowed, getResizingColumn, getTable, getToolTipText, getUI, getUIClassID, getUpdateTableInRealTime, initializeLocalVars, paramString, resizeAndRepaint, setColumnModel, setDefaultRenderer, setDraggedColumn, setDraggedDistance, setReorderingAllowed, setResizingAllowed, setResizingColumn, setUI, setUpdateTableInRealTime, updateUI
addAncestorListener, addNotify, 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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, 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
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, 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, transferFocusDownCycle, validate, validateTree
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, 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, transferFocusBackward, transferFocusUpCycle
protected boolean autoResizingEnabled
protected boolean includeHeaderWidth
public ResizeableTableHeader()
ResizeableTableHeader
with a default
TableColumnModel
.public ResizeableTableHeader(javax.swing.table.TableColumnModel cm)
ResizeableTableHeader
which is initialized with
cm
as the column model. If cm
is
null
this method will initialize the table header
with a default TableColumnModel
.cm
- the column model for the tablepublic void setTable(javax.swing.JTable table)
setTable
in class javax.swing.table.JTableHeader
table
- the new tablepublic void setAutoResizingEnabled(boolean autoResizingEnabled)
autoResizingEnabled
- true if columns are resized automaticallygetAutoResizingEnabled()
public boolean getAutoResizingEnabled()
autoResizingEnabled
propertysetAutoResizingEnabled(boolean)
public void setIncludeHeaderWidth(boolean includeHeaderWidth)
includeHeaderWidth
- true if the headers are includedgetIncludeHeaderWidth()
public boolean getIncludeHeaderWidth()
setIncludeHeaderWidth
propertysetIncludeHeaderWidth(boolean)
public void resizeColumn(javax.swing.table.TableColumn column)
column
- The TableColumn
to resize.public void resizeAllColumns()
public void setColumnWidths(javax.swing.table.TableColumn column, int preferredWidth, int minWidth, int maxWidth)
column
- The TableColumn
to change.preferredWidth
- The preferred width of the column.minWidth
- The minimum width of the column.maxWidth
- The maximum width of the column.setAllColumnWidths(int preferredWidth, int minWidth, int maxWidth)
public void setAllColumnWidths(int preferredWidth, int minWidth, int maxWidth)
preferredWidth
- The preferred width of the column.minWidth
- The minimum width of the column.maxWidth
- The maximum width of the column.setColumnWidths(javax.swing.table.TableColumn column,int preferredWidth, int minWidth, int maxWidth)
public void tableChanged(javax.swing.event.TableModelEvent e)
resizeAllColumns()
.tableChanged
in interface javax.swing.event.TableModelListener
e
- The TableModelEvent