这个压缩包里的都是超级经典的java例子
源代码在线查看: tips.htm
Setting Tool Tips on Cells in a JTable Component (Java Developers Almanac Example)
The Java Developers Almanac 1.4
Order this book from Amazon.
google_ad_client = "pub-6001183370374757";
google_ad_width = 120;
google_ad_height = 600;
google_ad_format = "120x600_as";
google_ad_channel = "4777242811";
google_ad_type = "text_image";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "6666CC";
google_color_url = "6666CC";
google_color_text = "000000";
//-->
Home
>
List of Packages
>
javax.swing.table
[62 examples]
>
Tool Tips
[2 examples]
e938. Setting Tool Tips on Cells in a JTable Component
Unfortunately, there is no setToolTipText() method for cells in a
JTable component. For a cell to show a tool tip, the renderer
for that cell must set the tool tip text on the returned component.
See e928 Creating a Custom Cell Renderer in a JTable Component for an example of a renderer
that sets a tool tip.
If you cannot modify the renderer, you can override the table's
prepareRenderer() method and explicitly set the tool tip on the
returned component.
// This table displays a tool tip text based on the string
// representation of the cell value
JTable table = new JTable() {
public Component prepareRenderer(TableCellRenderer renderer,
int rowIndex, int vColIndex) {
Component c = super.prepareRenderer(renderer, rowIndex, vColIndex);
if (c instanceof JComponent) {
JComponent jc = (JComponent)c;
jc.setToolTipText((String)getValueAt(rowIndex, vColIndex));
}
return c;
}
};
Related Examples
e937.
Setting Column Header Tool Tips in a JTable Components
See also:
Cells
Column Heads
Columns
Editing
Events
Layout
Rows
Scrolling
Selection
Sorting
Table Model
© 2002 Addison-Wesley.