requireToolTip() does not work for table cells with dynamic tool tip content

16 views
Skip to first unread message

Jay Guidos

unread,
Oct 24, 2010, 11:41:25 AM10/24/10
to easyt...@googlegroups.com
Hi All,

I am trying to test tool tips where the actual tooltip is calculated dynamically by the table instead of directly consulting the compoent's tooltip text.  In particular I am providing a table override:

new JTable() {
  String getToolTipText(MouseEvent ev)
  {
     return getCustomToolTipForCellAtLocation(ev)'
  }
}

It seems that getToolTipText(MouseEvent ev) is generally called from events generated by the ToolTipManager timer.  Looking at your requireToolTip() method, the tooltip is retrieved by pulling it from the component's static getToolTipText() method, and my table method override is never called.

It appears I have two problems:

   1- I have tried a couple of different ways to trigger a mouse event to my table's getToolTipText(MouseEvent ev) handler, but clicking on the table or a table cell does not seem to get it done.   Perhaps it would work if I could generate a mouse move over the table cell without a click, but how?
   2- even if I solve (1), your requireToolTip() method will not pay attention to my dynamically calculated tooltip anyway

Any recommendations on how to solve these problems?

Jay

Alex Ruiz

unread,
Oct 29, 2010, 2:45:48 PM10/29/10
to easyt...@googlegroups.com
Hi Jay,

I don't have an immediate answer for you. This is the first time I see this use case (it is valid, I just didn't encounter it before.) Let me do some testing and see how we can support it.

Regards,
-Alex

--
You received this message because you are subscribed to the Google Groups "easytesting" group.
To post to this group, send email to easyt...@googlegroups.com.
To unsubscribe from this group, send email to easytesting...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/easytesting?hl=en.

Jay Guidos

unread,
Oct 29, 2010, 5:17:35 PM10/29/10
to easyt...@googlegroups.com
Thanks Alex!  I am looking forward to seeing what you come up with.

Jay

J3

unread,
Nov 8, 2010, 7:09:03 AM11/8/10
to easytesting
Hello Alex, and Jay (and sorry for hijacking your topic, but I think
it's closely related),

Jay describes overriding getToolTipText(), but there's another way to
provide cell-specific tooltip too, which is to set the renderer's
tooltip. I deem it's a preferrable design when it is possible, as it
doesn't require subclassing JTable, but it sometimes leads to clumsy
code when the tooltip depends on information that are not in the cell
alone.
This section of the Swing tutorial describes both approaches:
http://download.oracle.com/javase/tutorial/uiswing/components/table.html#celltooltip

Anyway, I met the same problem - how to test those tooltips...

Indeed I was about to post the exact same question (how to test cell-
specific tooltips), when I discovered Jay's post.
I hope you can suggest a solution that covers both approaches.

Best regards,

J.

On 29 oct, 19:45, Alex Ruiz <alex.ruiz...@gmail.com> wrote:
> Hi Jay,
>
> I don't have an immediate answer for you. This is the first time I see this
> use case (it is valid, I just didn't encounter it before.) Let me do some
> testing and see how we can support it.

> On Sun, Oct 24, 2010 at 8:41 AM, Jay Guidos <jay.gui...@gmail.com> wrote:
> > Hi All,
>
> > I am trying to test tool tips where the actual tooltip is calculated
> > dynamically by the table instead of directly consulting the compoent's
> > tooltip text.  In particular I am providing a table override (...)
>
> > new JTable() {
> >   String getToolTipText(MouseEvent ev)
> >   { ...}
> > }

Jay Guidos

unread,
Nov 8, 2010, 10:09:12 AM11/8/10
to easyt...@googlegroups.com
Hi there J,

Your observations are sound - indeed I was aware of being able to set the tooltip on the renderer.  And just as you commented, in this particular case my tool tips have dependencies that span the particular cell in question, and are more a consequence of the state of the entire model - so in this case I believe providing a table override is an appropriate approach.

Now all we need is Alex to come up with a brilliant way to integrate event-driven tool tips and we are good to go :)

Jay

> > }

Alex Ruiz

unread,
Nov 15, 2010, 10:20:00 PM11/15/10
to easytesting
Hey Jay,

I'll be looking into this tonight. My schedule has been pretty crazy
lately :(

Cheers!
-Alex

On Nov 8, 7:09 am, Jay Guidos <jay.gui...@gmail.com> wrote:
> Hi there J,
>
> Your observations are sound - indeed I was aware of being able to set the
> tooltip on the renderer.  And just as you commented, in this particular case
> my tool tips have dependencies that span the particular cell in question,
> and are more a consequence of the state of the entire model - so in this
> case I believe providing a table override is an appropriate approach.
>
> Now all we need is Alex to come up with a brilliant way to integrate
> event-driven tool tips and we are good to go :)
>
> Jay
>
>
>
>
>
>
>
> On Mon, Nov 8, 2010 at 5:09 AM, J3 <jeth...@gmail.com> wrote:
> > Hello Alex, and Jay (and sorry for hijacking your topic, but I think
> > it's closely related),
>
> > Jay describes overriding getToolTipText(), but there's another way to
> > provide cell-specific tooltip too, which is to set the renderer's
> > tooltip. I deem it's a preferrable design when it is possible, as it
> > doesn't require subclassing JTable, but it sometimes leads to clumsy
> > code when the tooltip depends on information that are not in the cell
> > alone.
> > This section of the Swing tutorial describes both approaches:
>
> >http://download.oracle.com/javase/tutorial/uiswing/components/table.h...
> > easytesting...@googlegroups.com<easytesting%2Bunsubscribe@googlegr oups.com>
> > .
Reply all
Reply to author
Forward
0 new messages