dcsimg
***URGENT***How could I make the tooltip test be shown whenever I want
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Pary_Alavi
Posted On:   Saturday, July 19, 2003 01:46 AM

Hi I have a drawing area class that is an extension for JPanel. I will draw some shapes such as circle,rectengle,... on it. I want my application to show different tooltip text when user clicks a circle shape, a rectengle shape and etc.... This means that when user clicks a circle shape I want to change the tooltip text of my instance of Jpanel to "Circle" and when clicks a rectengle change it as "Rect" but the problem is I want to make the tooltip text to be shown at the moment user clicks the shape, without need to move the cursor by the user to cause the tooltip text be shown. Remark: I have the location of the shapes that are drawn on dr   More>>

Hi


I have a drawing area class that is an extension for JPanel. I will draw some shapes such as circle,rectengle,... on it.


I want my application to show different tooltip text when user clicks a circle shape, a rectengle shape and etc.... This means that when user clicks a circle shape I want to change the tooltip text of my instance of Jpanel to "Circle" and when clicks a rectengle change it as "Rect"

			
				but the problem is
				
I want to make the tooltip text to be shown at the moment user clicks the shape, without need to move the cursor by the user to cause the tooltip text be shown.


Remark: I have the location of the shapes that are drawn on drawing area, so I have an search algorithm to know which shape is clicked.


thanx


Parvaneh

   <<Less

Re: ***URGENT***How could I make the tooltip test be shown whenever I want

Posted By:   Bahman_Barzideh  
Posted On:   Sunday, July 20, 2003 05:48 PM

You can look into two items. First, you can customize tooltip's behaviour
via the ToolTipManager class. Using this class you should
be able to make the tool tip appear immediately (on entering a
JComponent) and stay visible until the mouse leaves the
JComponent. I would guess there are two problems with
this approach for your purposes. First, you mention the tooltip is to
be displayed when a shape is clicked. tooltips do not rely on mouse
clicks for their behaviour, just its motion. The second is that you will
probably need to write a fair amount of code for correct behaviour of
the tooltip since I doubt the shapes you are drawing are JComponents.



Your other option, and I think the better one, is to develop you own
MouseListener. When the mouse is clicked you can display
an undecorated JWindow that contains the text you require (
you would determine the text to be displayed based on the location of the
mouse on your drawing panel). Note that depending on your requirements, you may also need to develop a MouseMotionListener to detect when the mouse leaves
and reenters the JPanel.
About | Sitemap | Contact