Careful on your use of the term 'swingers'!
I find it surprising that JList doesnt override getToolTipText(MouseEvent),
as JTable does. I would suggest overriding it for JList, to return the
tooltip text set on your renderer, to make up for Swing's shortcoming.
-----Original Message-----
From: Arnaud Hallais <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED] <[EMAIL PROTECTED]>; [EMAIL PROTECTED]
<[EMAIL PROTECTED]>
Date: Thursday, June 07, 2001 09:55
Subject: Re: Tooltips in JList
Ok swingers
I found the (at least one) solution in the Sun Community discussion
archive "Mr jay_suri had the same problem way back in 1999"
I needed to overwrite the method getToolTipText(MouseEvent ev) of the
JList component. the mouse event gives me the position of the mouse so I can
determine on which item it is on. I was probably day dreaming when I said
this way was not working because now it is!
About Marijn last tip, I found out that components returned by the
method getListCellRendererComponent are not currently added to the JList
panel. they are just used by the JList, which paints them in its own
graphical context. So setting a tooltips on these components is useless.
thanks for every one help
----- Original Message -----
From: Marijn H. van der Ploeg
To: Arnaud Hallais ; [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED] ; [EMAIL PROTECTED]
Sent: Thursday, June 07, 2001 10:06 AM
Subject: Re: Tooltips in JList
Hi,
Remember, you have to tell the Tooltipmanager that it's supposed to
pay attention:
ToolTipManager.sharedInstance().registerComponent(this); //
"this" is a JList-derivate
Cheers,
Marijn
----- Original Message -----
From: Arnaud Hallais
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED] ; [EMAIL PROTECTED]
Sent: Thursday, June 07, 2001 9:09 AM
Subject: Re: Tooltips in JList
Well I tryed your solution, and ...... back to the same point,No
tooltips! the JList component behaves like if it has one of these
transparent panel on top to catch all mouse events, so the JLabel items
never know the mouse is over them. Registering them to the ToolTipManager
has no effect.
here is my extension of the DefaultListCellRenderer class
class MyListCellRenderer extends DefaultListCellRenderer {
public Component getListCellRendererComponent(JList
list,Object value,int index,boolean sel,boolean focus) {
Component c =
super.getListCellRendererComponent(list,value,index,sel,focus);
if (c instanceof JLabel) {
// System.out.println("coucou
"+String.valueOf(index));
//
ToolTipManager.sharedInstance().registerComponent((JLabel)c);
((JLabel)c).setToolTipText("My tooltip for index
"+String.valueOf(index));
}
return c;
}
}
thanks
----- Original Message -----
From: Greg Munt
To: Arnaud Hallais ; [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED] ; [EMAIL PROTECTED]
Sent: Wednesday, June 06, 2001 5:46 PM
Subject: Re: Tooltips in JList
IIRC DefaultListCellRenderer returns JLabels cast to
Component. So, simply cast them to JComponent, to set the tool tip text.
-----Original Message-----
From: Arnaud Hallais <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Cc: [EMAIL PROTECTED] <[EMAIL PROTECTED]>; [EMAIL PROTECTED]
<[EMAIL PROTECTED]>
Date: Wednesday, June 06, 2001 04:32
Subject: Tooltips in JList
Hello,
I'd like to make a JList which displays different
tooltips depending on which item the mouse is on. Is there any simple way to
do this, I did not find it, sorry!
1 - I tryed to overwrite the JList method
getToolTipText() but I am missing the position of the mouse so I can't
determine which item is under the mouse
2 - I tryed to overwrite the DefaultListCellRenderer
method getListCellRendererComponent to has a tooltip to all of the item
coponents but they are Component not JComponent so no setTooltipText()
method.
3 - I am stuck!
thanks for any advise
a++
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing