File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes setToolTipText method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "setToolTipText method" Watch "setToolTipText method" New topic

setToolTipText method

Samer Telawi

Joined: Mar 23, 2013
Posts: 18
currently I am working on an application in which I have small JPanels that represent some Items and I can move them by clicking on anyone of them inside another JPanel I called it sessionPanel that holds all the others, but when I add setToolTipText for the movable jpanels
I can not move them anymore
does anyone can give me a reasonable explanation
Greg Brannon

Joined: Oct 24, 2010
Posts: 563
Can you post a SSCCE?

Always learning Java, currently using Eclipse on Fedora.
Linux user#: 501795
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4351

the location of the tool tip is relative to the location of the panel(like dialogs). if you can, delay calling the method until it is needed(like on mouse over).
not sure if that helps any.

Visit my download page
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2454
When you use setToolTipText() a MouseListener is added to the component so tool tip processing can be implemented. I would guess that this mouse listener is receiving the mouse event and consuming them so they don't get passed to your mouse listener.

Try changing you code to look something like:

Swing dispatches the event in reverser order that the mouse listener is added to the component so you listener should be executed first.
I agree. Here's the link:
subject: setToolTipText method
It's not a secret anymore!