|
Copyright © 2005 Scientific Applications. All Rights Reserved. | ||||||||
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.table.JTableHeader
com.sciapp.table.AdvancedTableHeader
public class AdvancedTableHeader
This is the object which manages the header of AdvancedJTable. This class does not let users reorder table columns when dragging them with the right mouse button pressed. It also disallows the reordering of the last dummy column (if that one exists).
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.table.JTableHeader |
---|
JTableHeader.AccessibleJTableHeader |
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 |
---|
Fields inherited from class javax.swing.table.JTableHeader |
---|
columnModel, draggedColumn, draggedDistance, reorderingAllowed, resizingAllowed, resizingColumn, table, updateTableInRealTime |
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 | |
---|---|
AdvancedTableHeader()
Constructs an AdvancedTableHeader. |
|
AdvancedTableHeader(TableColumnModel cm)
Constructs an AdvancedTableHeader which is initialized with cm as the column model. |
Method Summary | |
---|---|
void |
addNotify()
Notifies this component that it now has a parent component. |
protected boolean |
canMove(int fromIndex,
int toIndex)
Determines whether the column at fromIndex can be moved to toIndex . |
void |
columnWillBeAdded(TableColumnModelEvent e)
Invoked whenever a table column is about to be added. |
void |
columnWillBeMoved(TableColumnModelEvent e)
Invoked whenever a table column is about to be moved. |
void |
columnWillBeRemoved(TableColumnModelEvent e)
Invoked whenever a table column is about to be removed. |
protected TableColumnModel |
createDefaultColumnModel()
Creates a new instance of DefaultVetoableColumnModel . |
protected void |
doProcessMouseEvent(MouseEvent e)
Processes mouse events occurring on this component by dispatching them to any registered MouseListener objects. |
protected void |
doProcessMouseMotionEvent(MouseEvent e)
Processes mouse motion events, such as MouseEvent.MOUSE_DRAGGED. |
Component |
getComponentAtPoint(Point p)
Returns the component that is painted on the header at the point p. |
int |
getDraggedDistance()
Returns the column's horizontal distance from its original position, if and only if, a drag is in process. |
boolean |
getReorderingAllowed()
Returns true if the user is allowed to rearrange columns by dragging their headers, false otherwise. |
Point |
getToolTipLocation(MouseEvent event)
Returns the tooltip location in this component's coordinate system. |
String |
getToolTipText(MouseEvent event)
Allows the renderer's tips to be used if there is text set. |
protected boolean |
handleEvent(MouseEvent e,
Component comp)
Handles a mouse event on the header. |
protected void |
initializeLocalVars()
Initializes the local variables and properties with default values. |
boolean |
isReorderingAllowed(int index)
Returns true if the column at index is reorderable. |
boolean |
isReorderingAllowed(Point p)
Returns true if column reordering at the specified coordinate can be initiated. |
protected void |
processMouseEvent(MouseEvent e)
This method is overriden so that the mouse event is appropriately converted due to the presence of fixed/locked columns/rows. |
protected void |
processMouseMotionEvent(MouseEvent e)
This method is overriden so that the mouse event is appropriately converted due to the presence of fixed/locked columns/rows. |
void |
setColumnModel(TableColumnModel newModel)
Sets the column model for this table to newModel and registers
for listener notifications from the new column model. |
void |
setDraggedColumn(TableColumn col)
Sets the header's draggedColumn to aColumn . |
void |
setTable(JTable aTable)
Sets the table associated with this header. |
void |
updateUI()
Notification from the UIManager that the look and feel
(L&F) has changed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public AdvancedTableHeader()
public AdvancedTableHeader(TableColumnModel cm)
Method Detail |
---|
public void addNotify()
KeyboardAction
event listeners.
addNotify
in class JComponent
JComponent.registerKeyboardAction(java.awt.event.ActionListener, java.lang.String, javax.swing.KeyStroke, int)
protected boolean canMove(int fromIndex, int toIndex)
fromIndex
can be moved to toIndex
.
By default, this method returns true. You will need to override it in order to
define conditions for which columns cannot be moved.
fromIndex
- the current view index of the column being movedtoIndex
- the index the column is being moved to
public void columnWillBeAdded(TableColumnModelEvent e) throws ColumnModelVetoException
columnWillBeAdded
in interface VetoableTableColumnModelListener
e
- the event identifying the addition.
ColumnModelVetoException
public void columnWillBeMoved(TableColumnModelEvent e) throws ColumnModelVetoException
columnWillBeMoved
in interface VetoableTableColumnModelListener
e
- the event identifying the move.
ColumnModelVetoException
public void columnWillBeRemoved(TableColumnModelEvent e) throws ColumnModelVetoException
columnWillBeRemoved
in interface VetoableTableColumnModelListener
e
- the event identifying the removal.
ColumnModelVetoException
protected TableColumnModel createDefaultColumnModel()
DefaultVetoableColumnModel
.
Returns the default column model object which is
a DefaultTableColumnModel
. A subclass can override this
method to return a different column model object
createDefaultColumnModel
in class JTableHeader
protected void doProcessMouseEvent(MouseEvent e)
e
- the 'converted' mouse eventprotected void doProcessMouseMotionEvent(MouseEvent e)
e
- the 'converted' mouse eventpublic Component getComponentAtPoint(Point p)
p
- a point in the header's frame of reference
public int getDraggedDistance()
getDraggedDistance
in class JTableHeader
JTableHeader.getDraggedColumn()
public boolean getReorderingAllowed()
getReorderingAllowed
in class JTableHeader
reorderingAllowed
propertyJTableHeader.setReorderingAllowed(boolean)
public Point getToolTipLocation(MouseEvent event)
null
is returned, Swing will choose a location.
The default implementation returns null
.
getToolTipLocation
in class JComponent
event
- the MouseEvent
that caused the
ToolTipManager
to show the tooltip
null
public String getToolTipText(MouseEvent event)
getToolTipText
in class JTableHeader
event
- the location of the event identifies the proper
renderer and, therefore, the proper tip
protected boolean handleEvent(MouseEvent e, Component comp)
e
- the mouse event that triggered the methodcomp
- the drawn table cell component
protected void initializeLocalVars()
initializeLocalVars
in class JTableHeader
public boolean isReorderingAllowed(int index)
setFirstColumnFixed
).
index
- the index of the table column
public boolean isReorderingAllowed(Point p)
p
- object containing the x and y coordinates of the mouse event
protected void processMouseEvent(MouseEvent e)
doProcessMouseEvent
method is then called.
Processes mouse events occurring on this component by
dispatching them to any registered
MouseListener
objects.
This method is not called unless mouse events are enabled for this component. Mouse events are enabled when one of the following occurs:
MouseListener
object is registered
via addMouseListener
.
enableEvents
.
Note that if the event parameter is null
the behavior is unspecified and may result in an
exception.
processMouseEvent
in class Component
e
- the mouse eventMouseEvent
,
MouseListener
,
Component.addMouseListener(java.awt.event.MouseListener)
,
Component.enableEvents(long)
protected void processMouseMotionEvent(MouseEvent e)
doProcessMouseMotionEvent
method is then called.
Processes mouse motion events, such as MouseEvent.MOUSE_DRAGGED.
processMouseMotionEvent
in class JComponent
e
- the MouseEvent
MouseEvent
public void setColumnModel(TableColumnModel newModel)
newModel
and registers
for listener notifications from the new column model.
setColumnModel
in class JTableHeader
newModel
- the new data source for this tableJTableHeader.getColumnModel()
public void setDraggedColumn(TableColumn col)
draggedColumn
to aColumn
.
Application code will not use this method explicitly, it is used internally by the column dragging mechanism.
setDraggedColumn
in class JTableHeader
col
- the column being dragged, or null
if
no column is being draggedpublic void setTable(JTable aTable)
setTable
in class JTableHeader
aTable
- the new tablepublic void updateUI()
UIManager
that the look and feel
(L&F) has changed.
Replaces the current UI object with the latest version from the
UIManager
.
updateUI
in class JTableHeader
JComponent.updateUI()
|
Copyright © 2005 Scientific Applications. All Rights Reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |