aspose file tools
The moose likes Swing / AWT / SWT and the fly likes Clickable area Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "Clickable area" Watch "Clickable area" New topic
Author

Clickable area

Leonardo Fernandes
Greenhorn

Joined: Sep 24, 2003
Posts: 10
Hi,
How do I make a clickable area on a frame, so that an event listener can react when the area is clicked?
Thanks
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8265

If you are using AWT, extend java.awt.Component and override paint() to mark the region. If you are using Swing, extend javax.swing.JComponent and override paintComponent(). In either case, use setBounds() to set the region's position and size and add a MouseListener to receive the mouse click.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Manuel Moons
Ranch Hand

Joined: Mar 05, 2002
Posts: 229
Add a mouseListener to your component and check the coordinates that you want to using the MouseEvent's getX and getY methods.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Clickable area
 
Similar Threads
clickable text
Interactive Charts
How i can make a swing button to looks like arrow
WA #1.....word association
WA #2 ..... word association