Class SwingTableColumnWidthListener
- java.lang.Object
-
- java.awt.event.ComponentAdapter
-
- net.sf.jguiraffe.gui.platform.swing.builder.components.table.SwingTableColumnWidthListener
-
- All Implemented Interfaces:
ComponentListener
,EventListener
,TableColumnModelListener
public class SwingTableColumnWidthListener extends ComponentAdapter implements TableColumnModelListener
A specialized event listener class for keeping track of and resizing the columns of a table.
This class plays an important role in the Swing-specific implementation of tables with relative column widths. An instance is associated with a
TableColumnWidthController
object and registered as listener for certain events at a table component. In this constellation this class performs the following tasks:- When the table component is resized, it ensures that the widths of the columns are correctly set. This is especially important for columns with a percent width: the space available is distributed to the columns based on their relative width.
- When the user manually resizes a column the
TableColumnWidthController
is updated so that it is notified about the new column width.
This class is used internally by the Swing-specific table implementation. If a table has columns with a percent width, the component manager implementation creates an instance and registers it at the table. It is not intended to be used by applications directly.
- Version:
- $Id: SwingTableColumnWidthListener.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Constructor Summary
Constructors Constructor Description SwingTableColumnWidthListener(JTable tab, net.sf.jguiraffe.gui.builder.components.tags.table.TableColumnWidthController ctrl)
Creates a new instance ofSwingTableColumnWidthListener
and initializes it.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
columnAdded(TableColumnModelEvent e)
Dummy implementation of this method of theTableColumnModelListener
interface.void
columnMarginChanged(ChangeEvent e)
The width of a column has been changed.void
columnMoved(TableColumnModelEvent e)
Dummy implementation of this method of theTableColumnModelListener
interface.void
columnRemoved(TableColumnModelEvent e)
Dummy implementation of this method of theTableColumnModelListener
interface.void
columnSelectionChanged(ListSelectionEvent e)
Dummy implementation of this method of theTableColumnModelListener
interface.void
componentResized(ComponentEvent e)
The table monitored by this listener has been resized.-
Methods inherited from class java.awt.event.ComponentAdapter
componentHidden, componentMoved, componentShown
-
-
-
-
Constructor Detail
-
SwingTableColumnWidthListener
public SwingTableColumnWidthListener(JTable tab, net.sf.jguiraffe.gui.builder.components.tags.table.TableColumnWidthController ctrl)
Creates a new instance ofSwingTableColumnWidthListener
and initializes it.- Parameters:
tab
- the table to be monitoredctrl
- the associatedTableColumnWidthController
-
-
Method Detail
-
componentResized
public void componentResized(ComponentEvent e)
The table monitored by this listener has been resized. This implementation adjusts the column widths according to their specifications.- Specified by:
componentResized
in interfaceComponentListener
- Overrides:
componentResized
in classComponentAdapter
- Parameters:
e
- the event
-
columnAdded
public void columnAdded(TableColumnModelEvent e)
Dummy implementation of this method of theTableColumnModelListener
interface.- Specified by:
columnAdded
in interfaceTableColumnModelListener
- Parameters:
e
- the event
-
columnMarginChanged
public void columnMarginChanged(ChangeEvent e)
The width of a column has been changed. This implementation notifies theTableColumnWidthController
about this change. Note that this event is only processed if a column is currently resized. This is due to the fact that events of this type are also triggered by the automatic resizing mechanism.- Specified by:
columnMarginChanged
in interfaceTableColumnModelListener
- Parameters:
e
- the change event
-
columnMoved
public void columnMoved(TableColumnModelEvent e)
Dummy implementation of this method of theTableColumnModelListener
interface.- Specified by:
columnMoved
in interfaceTableColumnModelListener
- Parameters:
e
- the event
-
columnRemoved
public void columnRemoved(TableColumnModelEvent e)
Dummy implementation of this method of theTableColumnModelListener
interface.- Specified by:
columnRemoved
in interfaceTableColumnModelListener
- Parameters:
e
- the event
-
columnSelectionChanged
public void columnSelectionChanged(ListSelectionEvent e)
Dummy implementation of this method of theTableColumnModelListener
interface.- Specified by:
columnSelectionChanged
in interfaceTableColumnModelListener
- Parameters:
e
- the event
-
-