aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Event Handlers:Mouse over Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Event Handlers:Mouse over "circles"" Watch "Event Handlers:Mouse over "circles"" New topic
Author

Event Handlers:Mouse over "circles"

Sanjit Singh
Greenhorn

Joined: Nov 12, 2001
Posts: 27
Hi Everyone,
I am a beginner with Swing and I have to complete a project that is due soon. So I would be grateful if somebody could help me out.
I basically have a JFrame and a JPanel inside it to draw a few lines and circles. I am making a time graph inside the JPanel using raw x and y coordinates. I want to achieve the following:
1.I want to draw a small circle at the point where two lines meet.
2.I would also like to have a small pop up box with a message inside it when the user brings his mouse over this circle. I would not like to have a JOptionPane but instead a small window as I have lots of text (multiple lines)to display. When the user moves his mouse away from this circle, then the message box should close automatically.
I have already done point 1. by having a
public void paintComponent(Graphics g)
method in which I am using the graphics object to draw lines and circles.
PROBLEM: My main problem is in point 2, where I would like to add mouse listeners to this circle and somehow to implement this pop box. How can I achieve this? Can I have event handlers on a "circle" and that also inside the paintComponent method? Which swing component should I use for the popup window and how can I use it for my purpose?
Any help in this regard (sample code)would be highly appreciated. Thanks in advance!
Sanjit
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Here's a short example of how to use multiple tooltips on components that generate graphics... enjoy!



-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
 
subject: Event Handlers:Mouse over "circles"