aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Fire  the ToolTip in different way Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Fire  the ToolTip in different way" Watch "Fire  the ToolTip in different way" New topic
Author

Fire the ToolTip in different way

Shay Gaghe
Ranch Hand

Joined: Sep 03, 2001
Posts: 102
HI Coders
I've extended Jpanel and I draw an Image inside it so that Jpanel is the viewport of the image.
In usual circumstances when i mouse over the image's viewport the ToolTip execute ,but in my case I need to execute the ToolTipText without actually mouse over the image's viewport, instead I need to press a button which in turn execute the ToolTipText that registered with that image�s viewport.
I was thinking about dispatching mouse event but it must be more ways, How can I provide such a performance in efficient way?
Does the Jpanel able to capture mouse event ?
(code please)
thanks in advance
Shay Gaghe
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

The only way I've found that you can do this is by faking a mouse event in the ActionListener for the button... However, don't set a tool tip for the button, because the ToolTipManager will get confused and replace the tooltip you want to show with the buttons tooltip if you move the mouse around on the button after the tooltip is displayed...

Here's some code to mess around with...



-Nate


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Shay Gaghe
Ranch Hand

Joined: Sep 03, 2001
Posts: 102
wowww! you are good!!
thanks for your effrot , i'll try this.
Shay Gaghe
Shay Gaghe
Ranch Hand

Joined: Sep 03, 2001
Posts: 102
Hello Nathan
I have tried your code but it dont do what I expect it to do. The button doesnt executes the ToolTip that registered to the icon.
Can you check it again and notice me what is missing?
Sincerely
Shay Gaghe
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Are you just using the code I posted, or have you changed it some... if you have changed things ( other than just the path to the image, or things like that ), can you post the code you are trying to use it with now?

-Nate

Shay Gaghe
Ranch Hand

Joined: Sep 03, 2001
Posts: 102
Hi Nathan
I have copy and paste your entire code , the only change I made is the image path.
Sincerely
Shay

[This message has been edited by Shay Gaghe (edited October 19, 2001).]
Shay Gaghe
Ranch Hand

Joined: Sep 03, 2001
Posts: 102
Hi Nathan
i use JDK 1.3 , Swing
Shay
Shay Gaghe
Ranch Hand

Joined: Sep 03, 2001
Posts: 102
Hi Nathan
I stuck with that problem for several days. Its seem like you are the advanced programmer here who can help me.
Please
Shay Gaghe
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Sorry! I'm using the JDK 1.4... Sun must have added something that makes this work... I'm trying to figure out if I can get this to work under 1.3...

-Nate
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Actually, if you change the MouseEvent in the action listener from MouseEvent.MOUSE_ENTERED to MouseEvent.MOUSE_MOVED, it should work... sorry for the confusion...
New TipActivate class:
Shay Gaghe
Ranch Hand

Joined: Sep 03, 2001
Posts: 102
Hi Nathan
I tried to change the things as you said but its doesn�t work. I tried all the possible and the logic combination. Im sure its regarding to the version that I use (1.3 ) because I did the same thing with 1.1.2 version in success .
What you suggest me to do?
Thanks
Shay Gaghe
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Upgrade to 1.4? Just kidding... I think this might work... it appeared to work under the JDK 1.3 shipped with JBuilder 4... looks like for some reason, the 1.3 JDK requires you to have a MouseEntered event, then a MouseMoved event... not just one or the other by themselves...



-Nate
Shay Gaghe
Ranch Hand

Joined: Sep 03, 2001
Posts: 102
Hi Nathan
I tried it and its work perfectly ,
Thank you very much Nathan
Im very appreciate your effort
Sincerely
Shay Gaghe
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Fire the ToolTip in different way