Don't bother with text width and all that, In ToolTip.getToolTipText(...) :
// determine row r and column c where the mouseevent occurred
...
// retrieve the component at index (r,c)
Component comp =
myTable.getTableCellRendererComponent(null,myTable.getValueAt(r,c),false,fal
se,r,c)
// compare the component width to the table column width
TableColumn tc = myTable.getTableColumnModel().getColumn(c)
if (comp.getWidth() > tc.getWidth()) {
return myTable.getValueAt(r,c).toString(); // you might
want to change that to more serious way since you know what kind of object
getValueAt returns
} else
return null;
a++
----- Original Message -----
From: "panyamkm" <[EMAIL PROTECTED]>
To: "Arnaud Hallais" <[EMAIL PROTECTED]>
Sent: Monday, October 08, 2001 4:44 PM
Subject: Re: showing tooltips when content's length is more than JTable cell
width
> Hi ,
> Thank u very much for u r suggestion but how can i find the string
> width ,since the api Toolkit.getFontMetrics(Font font) has been
deprecated.
>
> If u have any info regarding the substitute please throw some
light
> on this.
>
> Thanks in advance
>
> Panyam
>
>
> ----- Original Message -----
> From: Arnaud Hallais <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, October 08, 2001 3:07 PM
> Subject: Re: showing tooltips when content's length is more than JTable
cell
> width
>
>
> > override JTable.getToolTipText(MouseEvent event) to return a text when
the
> > cell text is too wide and null otherwise. If the return tooltip text is
> > null, no tooltip is shown.
> > I didn't test it but it should work (I used this for JList)
> > Don't forget to register your table to the ToolTipManager with :
> > ToolTipManager.registerComponent(myTable);
> >
> > a++
> > ----- Original Message -----
> > From: "panyamkm" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Monday, October 08, 2001 10:51 AM
> > Subject: showing tooltips when content's length is more than JTable cell
> > width
> >
> >
> > > Hi all,
> > >
> > > I want to show tooltips only when content's length is more than JTable
> > cell
> > > width when user minimises the column.
> > >
> > > I am using JDK 1.2.2 .
> > >
> > >
> > > Thanks in Advance
> > >
> > > Thanks and Regards
> > > panyam
> > >
> > > _______________________________________________
> > > Advanced-swing mailing list
> > > [EMAIL PROTECTED]
> > > http://eos.dk/mailman/listinfo/advanced-swing
> >
> > _______________________________________________
> > Advanced-swing mailing list
> > [EMAIL PROTECTED]
> > http://eos.dk/mailman/listinfo/advanced-swing
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing