Java Reference
In-Depth Information
Using Tooltips
By default, your table cell renderers will display any tooltip text you've configured them to
display. Unlike with the
JTree
component, you don't need to manually register the table with
the
ToolTipManager
. If, however, your table doesn't display tooltip text, the table will respond
faster if you unregister the table with the
ToolTipManager
by using code such as the following:
// Explicitly
ToolTipManager.sharedInstance().unregisterComponent(aTable);
// Implicitly
yourTable.setToolTipText(null);
Handling JTable Events
There are no
JTable
events that you can register directly with the
JTable
. To find out when
something happens, you must register with one of the
JTable
model classes:
TableModel
,
TableColumnModel
, or
ListSelectionModel
.
Customizing a JTable Look and Feel
Each installable Swing look and feel provides a different
JTable
appearance and set of default
UIResource
value settings. Figure 18-8 shows the appearance of the
JTable
component for the
preinstalled set of look and feel types: Motif, Windows, and Ocean. In all three cases, the third
row is highlighted, where the coloration shows the first column is being edited.
-OTIF
7INDOWS
/CEAN
Figure 18-8.
JTable under different look and feel types
The available set of
UIResource
-related properties for a
JTable
is shown in Table 18-4.
The
JTable
component has 21 different properties.