javax.swing.table

Class JTableHeader

Implemented Interfaces:
Accessible, EventListener, ImageObserver, MenuContainer, Serializable, TableColumnModelListener

public class JTableHeader
extends JComponent
implements TableColumnModelListener, Accessible

This is the object which manages the header of the JTable.

Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeansTM has been added to the java.beans package. Please see XMLEncoder.

See Also:
javax.swing.JTable, Serialized Form

Nested Class Summary

protected class
JTableHeader.AccessibleJTableHeader
This class implements accessibility support for the JTableHeader class.

Nested classes/interfaces inherited from class javax.swing.JComponent

JComponent.AccessibleJComponent

Nested classes/interfaces inherited from class java.awt.Container

Container.AccessibleAWTContainer

Nested classes/interfaces inherited from class java.awt.Component

Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy

Field Summary

protected TableColumnModel
columnModel
The TableColumnModel of the table header.
protected TableColumn
draggedColumn
The index of the column being dragged.
protected int
draggedDistance
The distance from its original position the column has been dragged.
protected boolean
reorderingAllowed
If true, reordering of columns are allowed by the user; the default is true.
protected boolean
resizingAllowed
If true, resizing of columns are allowed by the user; the default is true.
protected TableColumn
resizingColumn
The index of the column being resized.
protected javax.swing.JTable
table
The table for which this object is the header; the default is null.
protected boolean
updateTableInRealTime
Obsolete as of Java 2 platform v1.3.

Fields inherited from class javax.swing.JComponent

TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW, accessibleContext, listenerList, ui

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

JTableHeader()
Constructs a JTableHeader with a default TableColumnModel.
JTableHeader(TableColumnModel cm)
Constructs a JTableHeader which is initialized with cm as the column model.

Method Summary

void
columnAdded(TableColumnModelEvent e)
Invoked when a column is added to the table column model.
int
columnAtPoint(Point point)
Returns the index of the column that point lies in, or -1 if it lies out of bounds.
void
columnMarginChanged(ChangeEvent e)
Invoked when a column is moved due to a margin change.
void
columnMoved(TableColumnModelEvent e)
Invoked when a column is repositioned.
void
columnRemoved(TableColumnModelEvent e)
Invoked when a column is removed from the table column model.
void
columnSelectionChanged(ListSelectionEvent e)
Invoked when the selection model of the TableColumnModel is changed.
protected TableColumnModel
createDefaultColumnModel()
Returns the default column model object which is a DefaultTableColumnModel.
protected TableCellRenderer
createDefaultRenderer()
Returns a default renderer to be used when no header renderer is defined by a TableColumn.
AccessibleContext
getAccessibleContext()
Gets the AccessibleContext associated with this JTableHeader.
TableColumnModel
getColumnModel()
Returns the TableColumnModel that contains all column information of this table header.
TableCellRenderer
getDefaultRenderer()
Returns the default renderer used when no headerRenderer is defined by a TableColumn.
TableColumn
getDraggedColumn()
Returns the the dragged column, if and only if, a drag is in process, otherwise returns null.
int
getDraggedDistance()
Returns the column's horizontal distance from its original position, if and only if, a drag is in process.
Rectangle
getHeaderRect(int column)
Returns the rectangle containing the header tile at column.
boolean
getReorderingAllowed()
Returns true if the user is allowed to rearrange columns by dragging their headers, false otherwise.
boolean
getResizingAllowed()
Returns true if the user is allowed to resize columns by dragging between their headers, false otherwise.
TableColumn
getResizingColumn()
Returns the resizing column.
javax.swing.JTable
getTable()
Returns the table associated with this header.
String
getToolTipText(MouseEvent event)
Allows the renderer's tips to be used if there is text set.
TableHeaderUI
getUI()
Returns the look and feel (L&F) object that renders this component.
String
getUIClassID()
Returns the suffix used to construct the name of the look and feel (L&F) class used to render this component.
boolean
getUpdateTableInRealTime()
Obsolete as of Java 2 platform v1.3.
protected void
initializeLocalVars()
Initializes the local variables and properties with default values.
protected String
paramString()
Returns a string representation of this JTableHeader.
void
resizeAndRepaint()
Sizes the header and marks it as needing display.
void
setColumnModel(TableColumnModel columnModel)
Sets the column model for this table to newModel and registers for listener notifications from the new column model.
void
setDefaultRenderer(TableCellRenderer defaultRenderer)
Sets the default renderer to be used when no headerRenderer is defined by a TableColumn.
void
setDraggedColumn(TableColumn aColumn)
Sets the header's draggedColumn to aColumn.
void
setDraggedDistance(int distance)
Sets the header's draggedDistance to distance.
void
setReorderingAllowed(boolean reorderingAllowed)
Sets whether the user can drag column headers to reorder columns.
void
setResizingAllowed(boolean resizingAllowed)
Sets whether the user can resize columns by dragging between headers.
void
setResizingColumn(TableColumn aColumn)
Sets the header's resizingColumn to aColumn.
void
setTable(javax.swing.JTable table)
Sets the table associated with this header.
void
setUI(TableHeaderUI ui)
Sets the look and feel (L&F) object that renders this component.
void
setUpdateTableInRealTime(boolean flag)
Obsolete as of Java 2 platform v1.3.
void
updateUI()
Notification from the UIManager that the look and feel (L&F) has changed.

Methods inherited from class javax.swing.JComponent

Component getNextFocusableComponent, addAncestorListener, addNotify, addVetoableChangeListener, boolean isManagingFocus, boolean requestDefaultFocus, computeVisibleRect, contains, createToolTip, extends EventListener> T[] getListeners, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI, void disable, void enable, void reshape, void setNextFocusableComponent

Methods inherited from class java.awt.Container

Component locate, Dimension minimumSize, Dimension preferredSize, Insets insets, add, add, add, add, add, addContainerListener, addImpl, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, doLayout, extends EventListener> T[] getListeners, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponentZOrder, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, int countComponents, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, list, list, paint, paintComponents, paramString, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree, void deliverEvent, void layout

Methods inherited from class java.awt.Component

Component locate, ComponentPeer getPeer, Dimension minimumSize, Dimension preferredSize, Dimension size, Point location, Rectangle bounds, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, boolean action, boolean gotFocus, boolean handleEvent, boolean inside, boolean isFocusTraversable, boolean keyDown, boolean keyUp, boolean lostFocus, boolean mouseDown, boolean mouseDrag, boolean mouseEnter, boolean mouseExit, boolean mouseMove, boolean mouseUp, boolean postEvent, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, doLayout, enableEvents, enableInputMethods, extends EventListener> T[] getListeners, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, hasFocus, imageUpdate, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusCycleRoot, isFocusOwner, isFocusable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, list, list, list, list, list, paint, paintAll, paramString, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFocusable, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate, void deliverEvent, void disable, void enable, void enable, void hide, void layout, void move, void nextFocus, void reshape, void resize, void resize, void show, void show

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

columnModel

protected TableColumnModel columnModel
The TableColumnModel of the table header.

draggedColumn

protected TableColumn draggedColumn
The index of the column being dragged. null if not dragging.

draggedDistance

protected int draggedDistance
The distance from its original position the column has been dragged.

reorderingAllowed

protected boolean reorderingAllowed
If true, reordering of columns are allowed by the user; the default is true.

resizingAllowed

protected boolean resizingAllowed
If true, resizing of columns are allowed by the user; the default is true.

resizingColumn

protected TableColumn resizingColumn
The index of the column being resized. null if not resizing.

table

protected javax.swing.JTable table
The table for which this object is the header; the default is null.

updateTableInRealTime

protected boolean updateTableInRealTime
Obsolete as of Java 2 platform v1.3. Real time repaints, in response to column dragging or resizing, are now unconditional.

Constructor Details

JTableHeader

public JTableHeader()
Constructs a JTableHeader with a default TableColumnModel.
Usages and Demos :

View More Examples of JTableHeader()
   1: 
   2:             JTableHeader header = new JTableHeader();
   3:              DefaultTableCellRenderer headerRenderer =
   4:                     (DefaultTableCellRenderer)header.getDefaultRenderer();
   5:             

View Full Code Here
   1:     private void initDelegate() {
   2:         JTableHeader header = new JTableHeader();
   3:         delegateRenderer = header.getDefaultRenderer();
   4: 
   5:     }

View Full Code Here
   1:         this.parameterTable.setModel(dtm);
   2:         JTableHeader jth = new JTableHeader();
   3:         jth.add(new JLabel("Name"));
   4:         jth.add(new JLabel("Value"));
   5:         jth.setTable(this.parameterTable);

View Full Code Here
   1:                 
   2:                 final Component renderer = new JTableHeader().getDefaultRenderer().getTableCellRendererComponent(null, "", false, false, -1, 0);
   3:                 JPanel panel = new JPanel(new BorderLayout());
   4:                 panel.add(renderer, BorderLayout.CENTER);
   5:                 scrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, panel);

View Full Code Here
   1:         
   2:         this.checkBoxList.setTableHeader(new JTableHeader());
   3:         this.checkBoxList.getTableHeader().setVisible(false);
   4:         this.checkBoxList.getTableHeader().setSize(0, 0);

View Full Code Here

JTableHeader

public JTableHeader(TableColumnModel cm)
Constructs a JTableHeader which is initialized with cm as the column model. If cm is null this method will initialize the table header with a default TableColumnModel.
Parameters:
cm - the column model for the table
Usages and Demos :

View More Examples of JTableHeader(TableColumnModel cm)
   1:     private CustomTableRender ctr = new CustomTableRender();
   2:     private JTableHeader tableHeader = new JTableHeader(getColumnModel());
   3:     
   4:     

View Full Code Here
   1:     TableColumn column = new TableColumn();
   2:     JTableHeader tableHeader = new JTableHeader(columnModel);
   3: 
   4:     IPInfoDataModel ipInfoDataModal = new IPInfoDataModel();
   5:     JTable jTable1 = new JTable(ipInfoDataModal);

View Full Code Here
   1:     contentTable.setShowGrid(false);
   2:     contentTable.setTableHeader(new javax.swing.table.JTableHeader(contentTable.getColumnModel()));
   3:     contentTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
   4:     contentTable.setMinimumSize(new Dimension(100,100));
   5:     contentTable.getSelectionModel().addListSelectionListener(this);

View Full Code Here
   1:     setInterCellSpacing(new Dimension(1,1));
   2:     setTableHeader(new JTableHeader(columnModel));
   3:     updateUI();
   4:   }

View Full Code Here

Method Details

columnAdded

public void columnAdded(TableColumnModelEvent e)
Invoked when a column is added to the table column model.

Application code will not use these methods explicitly, they are used internally by JTable.

Specified by:
columnAdded in interface TableColumnModelListener
Parameters:
e - the event received

columnAtPoint

public int columnAtPoint(Point point)
Returns the index of the column that point lies in, or -1 if it lies out of bounds.
Returns:
the index of the column that point lies in, or -1 if it lies out of bounds
Usages and Demos :

View More Examples of columnAtPoint(Point point)
   1:         setRowSelectionAllowed (false);
   2:         final JTableHeader header = getTableHeader();
   3:         header.addMouseListener (new MouseAdapter() {
   4:         ...
   5:                         clearSelection();
   6:                     int pick = header.columnAtPoint(e.getPoint());
   7:                     addColumnSelectionInterval (pick, pick);
   8:                 }
   9:             });

View Full Code Here

columnMarginChanged

public void columnMarginChanged(ChangeEvent e)
Invoked when a column is moved due to a margin change.

Application code will not use these methods explicitly, they are used internally by JTable.

Specified by:
columnMarginChanged in interface TableColumnModelListener
Parameters:
e - the event received

columnMoved

public void columnMoved(TableColumnModelEvent e)
Invoked when a column is repositioned.

Application code will not use these methods explicitly, they are used internally by JTable.

Specified by:
columnMoved in interface TableColumnModelListener
Parameters:
e - the event received

columnRemoved

public void columnRemoved(TableColumnModelEvent e)
Invoked when a column is removed from the table column model.

Application code will not use these methods explicitly, they are used internally by JTable.

Specified by:
columnRemoved in interface TableColumnModelListener
Parameters:
e - the event received

columnSelectionChanged

public void columnSelectionChanged(ListSelectionEvent e)
Invoked when the selection model of the TableColumnModel is changed. This method currently has no effect (the header is not redrawn).

Application code will not use these methods explicitly, they are used internally by JTable.

Specified by:
columnSelectionChanged in interface TableColumnModelListener
Parameters:
e - the event received

createDefaultColumnModel

protected TableColumnModel createDefaultColumnModel()
Returns the default column model object which is a DefaultTableColumnModel. A subclass can override this method to return a different column model object
Returns:
the default column model object

createDefaultRenderer

protected TableCellRenderer createDefaultRenderer()
Returns a default renderer to be used when no header renderer is defined by a TableColumn.
Returns:
the default table column renderer

getAccessibleContext

public AccessibleContext getAccessibleContext()
Gets the AccessibleContext associated with this JTableHeader. For JTableHeaders, the AccessibleContext takes the form of an AccessibleJTableHeader. A new AccessibleJTableHeader instance is created if necessary.
Specified by:
getAccessibleContext in interface Accessible
Overrides:
getAccessibleContext in interface JComponent
Returns:
an AccessibleJTableHeader that serves as the AccessibleContext of this JTableHeader

getColumnModel

public TableColumnModel getColumnModel()
Returns the TableColumnModel that contains all column information of this table header.
Returns:
the columnModel property
Usages and Demos :

View More Examples of getColumnModel()
   1: import javax.swing.event.MouseInputAdapter;
   2: import javax.swing.table.JTableHeader;
   3: import javax.swing.table.TableColumn;
   4:         ...
   5:   public final static int DESCENDING_SORT= -1;
   6:   protected JTableHeader tableHeader_;
   7:   private SortDescription sort_;
   8:         ...
   9:       int column) {
  10:       TableColumn col= tableHeader_.getColumnModel().getColumn(column);
  11:       setIcon(getSortIcon(col));
  12:         ...
  13:         valideAction_= true;
  14:         TableColumnModel model= tableHeader_.getColumnModel();

View Full Code Here
   1: import jp.ujihara.javax.swing.plaf.TableHeaderUI;
   2: import jp.ujihara.javax.swing.table.JTableHeader;
   3: import jp.ujihara.javax.swing.table.TableCellRenderer;
   4:         ...
   5: 
   6:   protected JTableHeader header;
   7:   protected MouseInputListener mouseInputListener;
   8:         ...
   9:   {
  10:     header = (JTableHeader) c;
  11:     installDefaults();
  12:         ...
  13:   {
  14:     TableColumnModel cmod = header.getColumnModel();

View Full Code Here
   1: import javax.swing.JScrollPane;
   2: import javax.swing.table.JTableHeader;
   3: import javax.swing.table.TableColumn;
   4:         ...
   5:     table.setFont(isFontLarge ? Constants.FONT_LARGE : Constants.FONT_NORMAL);
   6:     JTableHeader tableHeader = table.getTableHeader();
   7:     tableHeader.setResizingAllowed(true);
   8:         ...
   9:     TableColumn nameColumn =
  10:       tableHeader.getColumnModel().getColumn(COLUMN_NAME);
  11:     nameColumn.setPreferredWidth(2 * nameColumn.getPreferredWidth());
  12:         ...
  13:   protected void tableHeader_mousePressed(MouseEvent event) {
  14:     JTableHeader tableHeader = table.getTableHeader();

View Full Code Here
   1: import javax.swing.border.Border;
   2: import javax.swing.table.JTableHeader;
   3: import javax.swing.table.TableCellRenderer;
   4:         ...
   5:         table = new JTable(new Object[0][0], columns);
   6:         JTableHeader header = table.getTableHeader();
   7:         header.setReorderingAllowed(false);
   8:         ...
   9:         SortButtonRenderer renderer = new SortButtonRenderer();
  10:         TableColumnModel model = table.getColumnModel();
  11:         int n = columns.length;
  12:         ...
  13:         
  14:         for (int i = 0; i < header.getColumnModel().getColumnCount(); i++) {

View Full Code Here
   1: import javax.swing.table.TableColumnModel;
   2: import javax.swing.table.JTableHeader;
   3: import javax.swing.event.ListSelectionEvent;
   4:         ...
   5:       this.idsDialogAccess);
   6:     table.getColumnModel().
   7:       getColumn(AttributeTableCellEditor.ATTRIBUTE_COLUMN_VALUE).
   8:         ...
   9:     table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
  10:     JTableHeader tableHeader = table.getTableHeader();
  11:     tableHeader.setResizingAllowed(true);
  12:         ...
  13:     tableHeader.setReorderingAllowed(false);
  14:     TableColumn valueColumn = tableHeader.getColumnModel().

View Full Code Here

getDefaultRenderer

public TableCellRenderer getDefaultRenderer()
Returns the default renderer used when no headerRenderer is defined by a TableColumn.
Returns:
the default renderer
Usages and Demos :

View More Examples of getDefaultRenderer()
   1: 
   2:         JTableHeader header = table.getTableHeader();
   3:         ...
   4:         TableCellRenderer oldRenderer = header.getDefaultRenderer();
   5:         String name = oldRenderer.getClass().getName();
   6:         ...
   7:             if (table != null) {
   8:                 JTableHeader header = table.getTableHeader();
   9:                 if (header != null) {

View Full Code Here
   1: import javax.swing.event.TableModelEvent;
   2: import javax.swing.table.JTableHeader;
   3: import javax.swing.table.TableCellRenderer;
   4:         ...
   5:     {
   6:         JTableHeader header = getTableHeader();
   7:         for(int column = 0; column < width.length; column++)
   8:         ...
   9:                     continue;
  10:                 renderer = header.getDefaultRenderer();
  11:                 if(renderer == null)

View Full Code Here
   1: import javax.swing.table.DefaultTableCellRenderer;
   2: import javax.swing.table.JTableHeader;
   3: import javax.swing.table.TableCellRenderer;
   4:         ...
   5:         if (table != null) {
   6:             JTableHeader header = table.getTableHeader();
   7:             try {
   8:         ...
   9:                 if (header != null) {
  10:                     TableCellRenderer tcr = header.getDefaultRenderer();
  11:                     Component c = tcr.getTableCellRendererComponent(

View Full Code Here
   1: import jp.ujihara.javax.swing.plaf.TableHeaderUI;
   2: import jp.ujihara.javax.swing.table.JTableHeader;
   3: import jp.ujihara.javax.swing.table.TableCellRenderer;
   4:         ...
   5: 
   6:   protected JTableHeader header;
   7:   protected MouseInputListener mouseInputListener;
   8:         ...
   9:   {
  10:     header = (JTableHeader) c;
  11:     installDefaults();
  12:         ...
  13:     Rectangle clip = gfx.getClipBounds();
  14:     TableCellRenderer defaultRend = header.getDefaultRenderer();

View Full Code Here
   1: 
   2: import javax.swing.table.JTableHeader;
   3: import javax.swing.table.TableCellRenderer;
   4:         ...
   5:             if (renderer == null) {
   6:                 JTableHeader header = table.getTableHeader();
   7:                 if (header != null) {
   8:         ...
   9:                     renderer = header.getDefaultRenderer();
  10:                 }

View Full Code Here

getDraggedColumn

public TableColumn getDraggedColumn()
Returns the the dragged column, if and only if, a drag is in process, otherwise returns null.
Returns:
the dragged column, if a drag is in process, otherwise returns null
Usages and Demos :

View More Examples of getDraggedColumn()
   1: import javax.swing.plaf.basic.BasicTableUI;
   2: import javax.swing.table.JTableHeader;
   3: import javax.swing.table.TableCellRenderer;
   4:         ...
   5:     {
   6:         JTableHeader header = table.getTableHeader();
   7:         ...
   8:         TableColumn draggedColumn = (header == null) ? null : header.getDraggedColumn();

View Full Code Here
   1: import javax.swing.event.TableColumnModelEvent;
   2: import javax.swing.table.JTableHeader;
   3: import javax.swing.table.TableCellRenderer;
   4:         ...
   5: 
   6: public class SortableTableHeader extends JTableHeader {
   7:     public static final String SORT_ASCENDING_PROPERTY="sortAscending";
   8:         ...
   9:         public Component getTableCellRendererComponent(JTable table,Object value,boolean isSelected, boolean hasFocus,int row,int column) {
  10:             JTableHeader header=table.getTableHeader();
  11:             setForeground(header.getForeground());
  12:         ...
  13:             TableColumn columnObject=header.getColumnModel().getColumn(column);
  14:             m_drawDepressed=(header.getDraggedColumn()==columnObject) || (m_mouseSelectedColumn==columnObject);

View Full Code Here

getDraggedDistance

public int getDraggedDistance()
Returns the column's horizontal distance from its original position, if and only if, a drag is in process. Otherwise, the the return value is meaningless.
Returns:
the column's horizontal distance from its original position, if a drag is in process, otherwise the return value is meaningless
Usages and Demos :

View More Examples of getDraggedDistance()
   1: import javax.swing.plaf.basic.BasicTableUI;
   2: import javax.swing.table.JTableHeader;
   3: import javax.swing.table.TableCellRenderer;
   4:         ...
   5:     {
   6:         JTableHeader header = table.getTableHeader();
   7:         TableColumn draggedColumn = (header == null) ? null : header.getDraggedColumn();
   8:         ...
   9:         {
  10:             paintDraggedArea(g, rMin, rMax, draggedColumn, header.getDraggedDistance());
  11:         }

View Full Code Here
   1:  {
   2:     JTableHeader header = table.getTableHeader(); 
   3:     TableColumn draggedColumn = (header == null) ? null : header.getDraggedColumn(); 
   4:         ...
   5:     { 
   6:         paintDraggedArea(g, rMin, rMax, draggedColumn, header.getDraggedDistance()); 
   7:     }
   8: 
   9:     rendererPane.removeAll(); 

View Full Code Here

getHeaderRect

public Rectangle getHeaderRect(int column)
Returns the rectangle containing the header tile at column. When the column parameter is out of bounds this method uses the same conventions as the JTable method getCellRect.
Returns:
the rectangle containing the header tile at column
See Also:
JTable.getCellRect
Usages and Demos :

View More Examples of getHeaderRect(int column)
   1: import javax.swing.event.MouseInputAdapter;
   2: import javax.swing.table.JTableHeader;
   3: import javax.swing.table.TableColumn;
   4:         ...
   5:   public final static int DESCENDING_SORT= -1;
   6:   protected JTableHeader tableHeader_;
   7:   private SortDescription sort_;
   8:         ...
   9:         pressedColumn_= model.getColumn(s);
  10:         tableHeader_.repaint(tableHeader_.getHeaderRect(s));
  11:         validateMouseEvent(_evt);
  12:         ...
  13:         pressedColumn_= null;
  14:         tableHeader_.repaint(tableHeader_.getHeaderRect(colSelectedIndex));

View Full Code Here
   1: 
   2:     static class ResizingTableHeader extends JTableHeader {
   3: 
   4:         ...
   5:         if (col < splitColumn) {
   6:             JTableHeader th = left.getTableHeader();
   7:         ...
   8:             th.repaint(th.getHeaderRect(col));
   9:         } else {
  10:         ...
  11:             JTableHeader th = right.getTableHeader();

View Full Code Here
   1: import javax.swing.table.DefaultTableCellRenderer;
   2: import javax.swing.table.JTableHeader;
   3: import javax.swing.table.TableCellRenderer;
   4:         ...
   5:     public void handleHeaderColumnLeftClick(Point p) {
   6:         JTableHeader th = TABLE.getTableHeader();
   7:         int col = th.columnAtPoint(p);
   8:         ...
   9:             sortAndMaintainSelection(c);
  10:             th.repaint(th.getHeaderRect(col));
  11:             if(oldC != -1 && oldC != c) {
  12:         ...
  13:                 int oldCol = TABLE.convertColumnIndexToView(oldC);
  14:                 th.repaint(th.getHeaderRect(oldCol));

View Full Code Here

getReorderingAllowed

public boolean getReorderingAllowed()
Returns true if the user is allowed to rearrange columns by dragging their headers, false otherwise. The default is true. You can rearrange columns programmatically regardless of this setting.
Returns:
the reorderingAllowed property

getResizingAllowed

public boolean getResizingAllowed()
Returns true if the user is allowed to resize columns by dragging between their headers, false otherwise. The default is true. You can resize columns programmatically regardless of this setting.
Returns:
the resizingAllowed property

getResizingColumn

public TableColumn getResizingColumn()
Returns the resizing column. If no column is being resized this method returns null.
Returns:
the resizing column, if a resize is in process, otherwise returns null
Usages and Demos :

View More Examples of getResizingColumn()
   1: import javax.swing.event.MouseInputAdapter;
   2: import javax.swing.table.JTableHeader;
   3: import javax.swing.table.TableColumn;
   4:         ...
   5:   public final static int DESCENDING_SORT= -1;
   6:   protected JTableHeader tableHeader_;
   7:   private SortDescription sort_;
   8:         ...
   9:         if ((_evt.getModifiers() != MouseEvent.BUTTON1_MASK)
  10:           || (tableHeader_.getResizingColumn() != null)) {
  11:           valideAction_= false;

View Full Code Here
   1: import jp.ujihara.javax.swing.table.DefaultTableModel;
   2: import jp.ujihara.javax.swing.table.JTableHeader;
   3: import jp.ujihara.javax.swing.table.TableCellEditor;
   4:         ...
   5: 
   6:   protected JTableHeader tableHeader;
   7: 
   8:         ...
   9:     setInterCellSpacing(new Dimension(1,1));
  10:     setTableHeader(new JTableHeader(columnModel));
  11:     updateUI();
  12:         ...
  13:     if (tableHeader != null)
  14:       resizingColumn = tableHeader.getResizingColumn();

View Full Code Here

getTable

public javax.swing.JTable getTable()
Returns the table associated with this header.
Returns:
the table property
Usages and Demos :

View More Examples of getTable()
   1: 
   2: import javax.swing.table.JTableHeader;
   3: 
   4:         ...
   5: 
   6:         final JTableHeader header = (JTableHeader) e.getComponent();
   7: 
   8:         ...
   9:                 final int modelColumnIndex 
  10:                     = header.getTable().convertColumnIndexToModel(columnIndex);
  11:                 if (this.model.isSortable(modelColumnIndex)) {
  12:         ...
  13:                     this.sortColumnIndex = header.getTable().convertColumnIndexToModel(columnIndex);

View Full Code Here
   1: import javax.swing.event.MouseInputAdapter;
   2: import javax.swing.table.JTableHeader;
   3: import javax.swing.table.TableColumn;
   4:         ...
   5:   public final static int DESCENDING_SORT= -1;
   6:   protected JTableHeader tableHeader_;
   7:   private SortDescription sort_;
   8:         ...
   9:   public JTable getTable() {
  10:     return tableHeader_.getTable();
  11:   }

View Full Code Here
   1: import jp.ujihara.javax.swing.plaf.TableHeaderUI;
   2: import jp.ujihara.javax.swing.table.JTableHeader;
   3: import jp.ujihara.javax.swing.table.TableCellRenderer;
   4:         ...
   5: 
   6:   protected JTableHeader header;
   7:   protected MouseInputListener mouseInputListener;
   8:         ...
   9:   {
  10:     header = (JTableHeader) c;
  11:     installDefaults();
  12:         ...
  13:             Object val = col.getHeaderValue();
  14:             Component comp = rend.getTableCellRendererComponent(header.getTable(),

View Full Code Here
   1: import javax.swing.border.Border;
   2: import javax.swing.table.JTableHeader;
   3: import javax.swing.table.TableCellRenderer;
   4:         ...
   5:         table = new JTable(new Object[0][0], columns);
   6:         JTableHeader header = table.getTableHeader();
   7:         header.setReorderingAllowed(false);
   8:         ...
   9:     class HeaderListener extends MouseAdapter {
  10:         JTableHeader header;
  11: 
  12:         ...
  13:             }
  14:             int sortCol = header.getTable().convertColumnIndexToModel(col);

View Full Code Here
   1:     private BrowserView browserView;
   2:     private JTableHeader header;
   3:     private FileCellRenderer renderer;
   4:         ...
   5:             {
   6:                 VFSDirectoryEntryTableModel model = (VFSDirectoryEntryTableModel) header.getTable().getModel();
   7:                 TableColumnModel columnModel = header.getColumnModel();
   8:                 int viewColumn = columnModel.getColumnIndexAtX(evt.getX());
   9:                 int column = columnModel.getColumn(viewColumn).getModelIndex();

View Full Code Here

getToolTipText

public String getToolTipText(MouseEvent event)
Allows the renderer's tips to be used if there is text set.
Overrides:
getToolTipText in interface JComponent
Parameters:
event - the location of the event identifies the proper renderer and, therefore, the proper tip
Returns:
the tool tip for this component

getUI

public TableHeaderUI getUI()
Returns the look and feel (L&F) object that renders this component.
Returns:
the TableHeaderUI object that renders this component

getUIClassID

public String getUIClassID()
Returns the suffix used to construct the name of the look and feel (L&F) class used to render this component.
Overrides:
getUIClassID in interface JComponent
Returns:
the string "TableHeaderUI"

getUpdateTableInRealTime

public boolean getUpdateTableInRealTime()
Obsolete as of Java 2 platform v1.3. Real time repaints, in response to column dragging or resizing, are now unconditional.

initializeLocalVars

protected void initializeLocalVars()
Initializes the local variables and properties with default values. Used by the constructor methods.

paramString

protected String paramString()
Returns a string representation of this JTableHeader. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null.

Overriding paramString to provide information about the specific new aspects of the JFC components.

Overrides:
paramString in interface JComponent
Returns:
a string representation of this JTableHeader

resizeAndRepaint

public void resizeAndRepaint()
Sizes the header and marks it as needing display. Equivalent to revalidate followed by repaint.
Usages and Demos :

View More Examples of resizeAndRepaint()
   1: import javax.swing.event.MouseInputAdapter;
   2: import javax.swing.table.JTableHeader;
   3: import javax.swing.table.TableColumn;
   4:         ...
   5:   public final static int DESCENDING_SORT= -1;
   6:   protected JTableHeader tableHeader_;
   7:   private SortDescription sort_;
   8:         ...
   9:     private void updateTable() {
  10:       tableHeader_.resizeAndRepaint();
  11:     }

View Full Code Here
   1:                     }
   2:                     JTableHeader th = tableView.getTableHeader();
   3:         ...
   4:                     th.resizeAndRepaint();
   5: 
   6:         ...
   7:         };
   8:         JTableHeader th = tableView.getTableHeader();
   9:         th.addMouseListener(listMouseListener);
  10:         ...
  11:             if (table != null) {
  12:                 JTableHeader header = table.getTableHeader();

View Full Code Here

setColumnModel

public void setColumnModel(TableColumnModel columnModel)
Sets the column model for this table to newModel and registers for listener notifications from the new column model.
Parameters:
columnModel - the new data source for this table
Throws:
IllegalArgumentException - if newModel is null

setDefaultRenderer

public void setDefaultRenderer(TableCellRenderer defaultRenderer)
Sets the default renderer to be used when no headerRenderer is defined by a TableColumn.
Parameters:
defaultRenderer - the default renderer
Usages and Demos :

View More Examples of setDefaultRenderer(TableCellRenderer defaultRenderer)
   1: 
   2: import javax.swing.table.JTableHeader;
   3: 
   4:         ...
   5:     private void customizeTableHeader(KongaTable table) {
   6:         JTableHeader header = table.getTableHeader();
   7:         header.setReorderingAllowed(false);
   8:         ...
   9:         header.setDefaultRenderer(IntegrationUiStyleSheet.getGreenTableHeaderRenderer());
  10:     }

View Full Code Here
   1: import javax.swing.event.MouseInputAdapter;
   2: import javax.swing.table.JTableHeader;
   3: import javax.swing.table.TableColumn;
   4:         ...
   5:   public final static int DESCENDING_SORT= -1;
   6:   protected JTableHeader tableHeader_;
   7:   private SortDescription sort_;
   8:         ...
   9:     tableHeader_.addMouseMotionListener(listener);
  10:     tableHeader_.setDefaultRenderer(headerRenderer_);
  11:     pressedColumn_= null;

View Full Code Here
   1: import javax.swing.table.DefaultTableCellRenderer;
   2: import javax.swing.table.JTableHeader;
   3: import javax.swing.table.TableModel;
   4:         ...
   5:     private void customizeHeader() {
   6:         JTableHeader header = getTableHeader();
   7:         header.setReorderingAllowed(false);
   8:         ...
   9:         header.setDefaultRenderer(IntegrationUiStyleSheet.getGreenTableHeaderRenderer());
  10:     }

View Full Code Here
   1: 
   2:       JTableHeader th = rcViewTable.getTableHeader();
   3:       th.addMouseListener(ml);
   4:         ...
   5:             rcViewTable);
   6:       th.setDefaultRenderer(tcr);
   7: 
   8:       rcMainPanel = new JPanel(new BorderLayout());
   9:       rcMainPanel.add(rcCustomerPanel, BorderLayout.NORTH);

View Full Code Here

setDraggedColumn

public void setDraggedColumn(TableColumn aColumn)
Sets the header's draggedColumn to aColumn.

Application code will not use this method explicitly, it is used internally by the column dragging mechanism.

Parameters:
aColumn - the column being dragged, or null if no column is being dragged

setDraggedDistance

public void setDraggedDistance(int distance)
Sets the header's draggedDistance to distance.
Parameters:
distance - the distance dragged

setReorderingAllowed

public void setReorderingAllowed(boolean reorderingAllowed)
Sets whether the user can drag column headers to reorder columns.
Parameters:
reorderingAllowed - true if the table view should allow reordering; otherwise false
Usages and Demos :

View More Examples of setReorderingAllowed(boolean reorderingAllowed)
   1: 
   2:         JTableHeader tabHeader;
   3:         tabHeader = getTableHeader();
   4: 
   5:         SortTableCommand cmdSort = new SortTableCommand();

View Full Code Here
   1: 
   2: import javax.swing.table.JTableHeader;
   3: 
   4:         ...
   5:     private void customizeTableHeader(KongaTable table) {
   6:         JTableHeader header = table.getTableHeader();
   7:         ...
   8:         header.setReorderingAllowed(false);
   9:         header.setDefaultRenderer(IntegrationUiStyleSheet.getGreenTableHeaderRenderer());

View Full Code Here
   1: 
   2:         JTableHeader tabHeader;
   3:         tabHeader = orfTab.getTableHeader();
   4: 
   5:         SortTableCommand cmdSort = new SortTableCommand();

View Full Code Here
   1:     public void setReorderingAllowed(boolean sta) {
   2:         JTableHeader tabHeader;
   3:         tabHeader = resTab.getTableHeader();
   4:     }

View Full Code Here
   1:         searchRuleTable.setShowVerticalLines(false);
   2:         JTableHeader tableHeader = searchRuleTable.getTableHeader();
   3:         tableHeader.setResizingAllowed(false);
   4:         ...
   5:         tableHeader.setReorderingAllowed(false);
   6:         JCheckBox box = (JCheckBox) searchRuleTable.getDefaultRenderer(Boolean.class);
   7:         TableColumn column = searchRuleTable.getColumnModel().getColumn(0);
   8:         column.setMaxWidth( box.getPreferredSize().width+2 );

View Full Code Here

setResizingAllowed

public void setResizingAllowed(boolean resizingAllowed)
Sets whether the user can resize columns by dragging between headers.
Parameters:
resizingAllowed - true if table view should allow resizing
Usages and Demos :

View More Examples of setResizingAllowed(boolean resizingAllowed)
   1:         searchRuleTable.setShowVerticalLines(false);
   2:         JTableHeader tableHeader = searchRuleTable.getTableHeader();
   3:         ...
   4:         tableHeader.setResizingAllowed(false);
   5:         tableHeader.setReorderingAllowed(false);
   6:         JCheckBox box = (JCheckBox) searchRuleTable.getDefaultRenderer(Boolean.class);
   7:         TableColumn column = searchRuleTable.getColumnModel().getColumn(0);

View Full Code Here
   1: import javax.swing.*;
   2: import javax.swing.table.JTableHeader;
   3: import javax.swing.table.TableColumn;
   4:         ...
   5:         consequenceTable.setShowVerticalLines(false);
   6:         JTableHeader tableHeader = consequenceTable.getTableHeader();
   7:         ...
   8:         tableHeader.setResizingAllowed(false);
   9:         tableHeader.setReorderingAllowed(false);

View Full Code Here
   1: import javax.swing.*;
   2: import javax.swing.table.JTableHeader;
   3: import javax.swing.table.TableColumn;
   4:         ...
   5:         conditionsTable.setShowVerticalLines(false);
   6:         JTableHeader tableHeader = conditionsTable.getTableHeader();
   7:         ...
   8:         tableHeader.setResizingAllowed(false);
   9:         tableHeader.setReorderingAllowed(false);

View Full Code Here
   1: import javax.swing.*;
   2: import javax.swing.table.JTableHeader;
   3: import javax.swing.table.TableColumn;
   4:         ...
   5:         exceptionsTable.setShowVerticalLines(false);
   6:         JTableHeader tableHeader = exceptionsTable.getTableHeader();
   7:         ...
   8:         tableHeader.setResizingAllowed(false);
   9:         tableHeader.setReorderingAllowed(false);

View Full Code Here
   1: import javax.swing.event.ListSelectionListener;
   2: import javax.swing.table.JTableHeader;
   3: import javax.swing.table.TableColumn;
   4:         ...
   5:       });
   6:     JTableHeader tableHeader = table.getTableHeader();
   7:         ...
   8:     tableHeader.setResizingAllowed(true);
   9:     tableHeader.setReorderingAllowed(false);

View Full Code Here

setResizingColumn

public void setResizingColumn(TableColumn aColumn)
Sets the header's resizingColumn to aColumn.

Application code will not use this method explicitly, it is used internally by the column sizing mechanism.

Parameters:
aColumn - the column being resized, or null if no column is being resized

setTable

public void setTable(javax.swing.JTable table)
Sets the table associated with this header.
Parameters:
table - the new table
Usages and Demos :

View More Examples of setTable(JTable table)
   1: import javax.swing.table.DefaultTableModel;
   2: import javax.swing.table.JTableHeader;
   3: import javax.swing.tree.DefaultMutableTreeNode;
   4:         ...
   5:         this.parameterTable.setModel(dtm);
   6:         JTableHeader jth = new JTableHeader();
   7:         jth.add(new JLabel("Name"));
   8:         ...
   9:         jth.add(new JLabel("Value"));
  10:         jth.setTable(this.parameterTable);
  11:         this.parameterTable.setTableHeader(jth);

View Full Code Here
   1: import jp.ujihara.javax.swing.table.DefaultTableModel;
   2: import jp.ujihara.javax.swing.table.JTableHeader;
   3: import jp.ujihara.javax.swing.table.TableCellEditor;
   4:         ...
   5: 
   6:   protected JTableHeader tableHeader;
   7: 
   8:         ...
   9:     setInterCellSpacing(new Dimension(1,1));
  10:     setTableHeader(new JTableHeader(columnModel));
  11:     updateUI();
  12:         ...
  13:     if (tableHeader != null)
  14:       tableHeader.setTable(null);

View Full Code Here

setUI

public void setUI(TableHeaderUI ui)
Sets the look and feel (L&F) object that renders this component.
Parameters:
ui - the TableHeaderUI L&F object

setUpdateTableInRealTime

public void setUpdateTableInRealTime(boolean flag)
Obsolete as of Java 2 platform v1.3. Real time repaints, in response to column dragging or resizing, are now unconditional.
Usages and Demos :

View More Examples of setUpdateTableInRealTime(boolean flag)
   1: 
   2:         JTableHeader tabHeader;
   3:         tabHeader = getTableHeader();
   4: 
   5:         SortTableCommand cmdSort = new SortTableCommand();

View Full Code Here
   1: 
   2:         JTableHeader tabHeader;
   3:         tabHeader = orfTab.getTableHeader();
   4: 
   5:         SortTableCommand cmdSort = new SortTableCommand();

View Full Code Here

updateUI

public void updateUI()
Notification from the UIManager that the look and feel (L&F) has changed. Replaces the current UI object with the latest version from the UIManager.
Overrides:
updateUI in interface JComponent