|
|
|
|
Author |
Messages |
baric
Private
Gender: Male
Location:
Registered: Apr 2006
Status: Offline
Posts: 9
|
Posted Tuesday, May 2, 2006 @ 09:43:38
Hi there,
looking out at the tutorials section, there's a nice example how to use tooltips to show cut-off data in a jtable:
The example simply overrides getToolTipLocation and getToolTipText to display the content of a cell.
However, overriding these methods on dbtable does not work. And I can't see how to override the jtable which quicktable is using.
Someone got an idea?
regards
robert
Code: | | public Point getToolTipLocation(MouseEvent event) {
int row = getTable().rowAtPoint(event.getPoint());
int col = getTable().columnAtPoint(event.getPoint());
Object o = getValueAt(row, col);
if (o == null)
return null;
if (o.toString().equals(""))
return null;
Point pt = getTable().getCellRect(row, col, true).getLocation();
pt.translate(-1, -2);
return pt;
}
public String getToolTipText(MouseEvent event) {
super.getToolTipText(event);
int row = getTable().rowAtPoint(event.getPoint());
int col = getTable().columnAtPoint(event.getPoint());
Object o = getValueAt(row, col);
if (o == null)
return null;
if (o.toString().equals(""))
return null;
return o.toString();
}
|
|
|
Admin
Board Owner
Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9
|
Posted Thursday, May 4, 2006 @ 22:52:08
In order to make this work, you need to extend the JTable class and override the getToolTipLocation, getToolTipText methods. In quicktable you cannot extend the JTable class since it is not accessible to you. I think it is still possible to implement this tooltop by extending DBTable class
Code: | |
class DBTableWithToolTip extends DBTable
{
public Point getToolTipLocation(MouseEvent event) {
//the x,y position may be slightly off compared to JTable
//so account for any differences
//your code here
}
public String getToolTipText(MouseEvent event) {
//the x,y position may be slightly off compared to JTable
//so account for any differences
//your code here
}
}
//instead of instantiating DBTable instantiate your class
DBTableWithToolTip myDBTable = new DBTableWithToolTip();
|
|
We will try to incorporate this feature into quicktable if more users request for this feature.
|
baric
Private
Gender: Male
Location:
Registered: Apr 2006
Status: Offline
Posts: 9
|
Posted Friday, May 5, 2006 @ 05:23:09
Quote: | | Originally posted by Admin
In order to make this work, you need to extend the JTable class and override the getToolTipLocation, getToolTipText methods. In quicktable you cannot extend the JTable class since it is not accessible to you. I think it is still possible to implement this tooltop by extending DBTable class
|
|
Extending the JTable would indeed solve the problem. Any reason there's no setTable method or constructor with a JTable ?
regards
robert
|
Admin
Board Owner
Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9
|
Posted Sunday, May 14, 2006 @ 21:56:13
The basic idea of quicktable is to hide the complexeties of JTable. So we do not want users to create a JTable and pass it to quicktable, instead we want users to tell what data they want to display and we will create a JTable for them. That is why there is no setTable() method.
|
hcir
Private
Gender: Male
Location: alaska
Registered: Oct 2006
Status: Offline
Posts: 7
|
Posted Sunday, November 5, 2006 @ 23:38:29
has the example below for class DBTableWithToolTip extends DBTable been tested? does this work? if not is there a method to enable tooltips for specific cells? I am working on a loggin app which has some lengthy messages for the main part of the log, would like to have a clean one line display of the major parts with the full content of the log message part being the tooltip
thanks
|
Admin
Board Owner
Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9
|
Posted Wednesday, November 8, 2006 @ 07:04:20
It is few lines of code, can you give a try?
|
hcir
Private
Gender: Male
Location: alaska
Registered: Oct 2006
Status: Offline
Posts: 7
|
Posted Tuesday, November 14, 2006 @ 17:56:37
Since I am new to Java I have not been able to get this to work, can anyone offer an example?
thanks
|
|
|
|
|
|
|
|
Login |
|
In order to fully utilize the abilities of this board, you are required to register as a member. Registration is free, and allows you to do lots of things including turning on or off certain features of this board. Register now! |
|
|
Powered by CuteCast v2.0 BETA 2
Copyright © 2001-2003 ArtsCore Studios
|
|