Home arrow static arrow Java Programming [Archive] - multiple tool tips
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - multiple tool tips
This topic has 3 replies on 1 page.

Posts:12
Registered: 7/29/04
multiple tool tips  
Aug 5, 2004 1:26 PM



 
I hope somebody can help me on this. I am trying to apply two different tool tips to the same component. One will be displayed as the mouse hovers over it and the other will be displayed by pressing F1. Is this possible?

 

Posts:105
Registered: 6/8/04
Re: multiple tool tips  
Aug 5, 2004 1:35 PM (reply 1 of 3)



 
Sure; just use a KeyListener to listen for F1 presses, and when the user pushes F1, change the ToolTipText.
 

Posts:12
Registered: 7/29/04
Re: multiple tool tips  
Aug 6, 2004 11:37 AM (reply 2 of 3)



 
Thanks RiOrius. One more question, am I able to change the popup method of the tooltip from Ctrl-F1 to just F1 by itself?
 

Posts:105
Registered: 6/8/04
Re: multiple tool tips  
Aug 6, 2004 11:48 AM (reply 3 of 3)



 
One more question, am I able to change the popup method of the tooltip from Ctrl-F1 to just F1 by itself?

Well, maybe. I sought tooltip advice earlier, and someone named phawdon gave me some of the following code snippet; it never worked for me, but then again, CTRL+F1 never worked for me, either, so if CTRL+F1 works for you, this should work...

public void keyPressed(KeyEvent e){        if(e.getKeyCode() == KeyEvent.VK_F1)        {                Component c = (Component)e.getSource();                c.dispatchEvent( new KeyEvent (c, KeyEvent.KEY_PRESSED, 0, KeyEvent.CTRL_MASK,                                         KeyEvent.VK_F1) );}};        }}


Use a KeyListener as such, so that when the user hits F1, a KeyEvent corresponding to CTRL+F1 is dispatched, hopefully causing the ToolTip to show itself. It might work, but I'm not sure...
 
This topic has 3 replies on 1 page.