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 JToolTip Problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JToolTip Problems" Watch "JToolTip Problems" New topic

JToolTip Problems

Terry McKee
Ranch Hand

Joined: Sep 29, 2000
Posts: 175
I have several components that make up a status bar at the bottom of JFrame. Each of these components have a JToolTip associated with them. When the JFrame is maximized I run into problems with the Tool Tips. It looks like by default, the Tooltips are shown just below the point where the mouse is located. I know that there must be a way to adjust this so the tool tips are located just above where the mouse is located (instead of below).

I have tried extending JToolTip and overriding the setVisible() method to check and adjust its location prior to displaying, but that doesn't work (in fact when debugging it doesn't even seem to execute this code).

I am going to try overriding the getLocation / setLocation methods and see if that works.

Does anyone have any suggestions?


Terry McKee
Ranch Hand

Joined: Sep 29, 2000
Posts: 175
This code seems passable for my situation:

public Point getToolTipLocation(MouseEvent event) {
Point result = null;
Component l_topFrame = MainView.this; //(Top Level Frame)
int l_topHeight = l_topFrame.getHeight();
if (l_topHeight > Toolkit.getDefaultToolkit().getScreenSize().getHeight() - 50)
result = new Point(0, 0);
return result;

I override this method in each of the components in my status bar. Does anyone know how to get the ToolTip above the actual component though?
[ September 29, 2005: Message edited by: Terry McKee ]
I agree. Here's the link:
subject: JToolTip Problems
jQuery in Action, 3rd edition