I am trying to get a multi-line tooltip on cells in a JTable. Basically
the cell is a large chunk of text, and I'd like to display it in the
tooltip.
First, you have to get any tooltip to display in a JTable. I created a
custom renderer which sets the tooltip text correctly, but the text
displays all in a single line. This works in the JTable.
I found some code for a multi-line tooltip renderer, but it relies on the
JComponent.createToolTip() method. I override this method in my custom
renderer, but it is never called when the renderer is used by a JTable.
Am I on the right track? If so, how do I get the JTable to use my
multiline tooltip renderer?
Thanks.
Chas Douglass
|
|
0
|
|
|
|
Reply
|
Chas
|
11/8/2004 8:58:55 PM |
|
On Mon, 08 Nov 2004 20:58:55 -0000, Chas Douglass wrote:
> I am trying to get a multi-line tooltip on cells in a JTable.
Did you try lurking in the group for a couple of days
before asking, or googling the group?
<http://groups.google.com/groups?selm=13klxlfeqhzg2$.msad2puffqve.dlg@40tude.net>
--
Andrew Thompson
http://www.PhySci.org/codes/ Web & IT Help
http://www.PhySci.org/ Open-source software suite
http://www.1point1C.org/ Science & Technology
http://www.LensEscapes.com/ Images that escape the mundane
|
|
0
|
|
|
|
Reply
|
Andrew
|
11/8/2004 9:15:41 PM
|
|
Hi,
>I am trying to get a multi-line tooltip on cells in a JTable. Basically
> the cell is a large chunk of text, and I'd like to display it in the
> tooltip.
Swing tooltips are capable of interpreting (simple) HTML - try inserting
<br> or similiar tags.
cu
Ren�
|
|
0
|
|
|
|
Reply
|
Rene
|
11/8/2004 9:29:51 PM
|
|
Andrew Thompson <SeeMySites@www.invalid> wrote in
news:1cmk3j618cb75$.sr7ahny9ulvt$.dlg@40tude.net:
> On Mon, 08 Nov 2004 20:58:55 -0000, Chas Douglass wrote:
>
>> I am trying to get a multi-line tooltip on cells in a JTable.
>
> Did you try lurking in the group for a couple of days
> before asking, or googling the group?
[snip]
Yes, I did. And while I'm sure you're frustrated with the number of
people that don't do that, I find your response frustrating since it
assumes that I didn't. What was that line from "Annie Hall"? Something
about "thanks for reducing me to a stereotype"??
I fully understand that tooltips will render HTML. I'm sorry I didn't
mention that in my original post, but it's difficult to know how many
things I should list that aren't what I want.
And while I'm certainly no expert on HTML, it would appear that it
requires me to calculate my own line breaks and insert the "<br>" tokens,
yes?
Clearly I should have mentioned (and I apologize for omitting it) that I
would like the text to "auto-wrap" in a "reasonably sized" tooltip.
Something like the automatic javadoc popups in Eclipse, but with word
wrap.
The path I was following was to subclass JToolTip and have it use a
JTextArea for the display of the text. While this seems reasonable to
me, JTable seems to have other ideas on how tooltips should be rendered.
Ideally, clicking on the cell to edit it would just change the tooltip
into an editable text area, as well.
Chas Douglass
|
|
0
|
|
|
|
Reply
|
Chas
|
11/8/2004 11:01:41 PM
|
|
Chas Douglass wrote:
> I am trying to get a multi-line tooltip on cells in a JTable. Basically
> the cell is a large chunk of text, and I'd like to display it in the
> tooltip.
>
> First, you have to get any tooltip to display in a JTable. I created a
> custom renderer which sets the tooltip text correctly, but the text
> displays all in a single line. This works in the JTable.
>
> I found some code for a multi-line tooltip renderer, but it relies on the
> JComponent.createToolTip() method. I override this method in my custom
> renderer, but it is never called when the renderer is used by a JTable.
>
> Am I on the right track? If so, how do I get the JTable to use my
> multiline tooltip renderer?
>
The TooltipManager would call the createTooltip method on the JTable in
order to create the tooltip, not on the renderer - so you need to
override the JTable's method instead of that of the renderer.
The JTable just "borrows" the text from the renderer if the renderer has
defined one. Since the renderer is not physically present on the screen,
they cannot receive events and hence there's no point registering them
with the TooltipManager.
BK
|
|
0
|
|
|
|
Reply
|
Babu
|
11/9/2004 7:11:58 AM
|
|
Babu Kalakrishnan <k.a.l.a@sankya.com> wrote in
news:2vb9coF2fmk4fU1@uni-berlin.de:
> Chas Douglass wrote:
[snip]
>>
>> Am I on the right track? If so, how do I get the JTable to use my
>> multiline tooltip renderer?
>>
>
> The TooltipManager would call the createTooltip method on the JTable
> in order to create the tooltip, not on the renderer - so you need to
> override the JTable's method instead of that of the renderer.
>
[snip]
Thanks, overriding createToolTip on the JTable fixed it. Exactly the
pointer I needed.
Chas Douglass
|
|
0
|
|
|
|
Reply
|
Chas
|
11/9/2004 3:20:29 PM
|
|
|
5 Replies
421 Views
(page loaded in 0.056 seconds)
|