Valhalla Legends Archive

Programming => General Programming => Java Programming => Topic started by: Tomcat on May 15, 2007, 11:19 PM

Title: How do I set just a specific area to trigger the actionPerformed() method?
Post by: Tomcat on May 15, 2007, 11:19 PM
I want the user to click on a specific area and have something trigger as a reaction to clicking in the specific area.  I do not want this area to be specially marked whatsoever.  An invisible button, if you will.
Title: Re: How do I set just a specific area to trigger the actionPerformed() method?
Post by: Hdx on May 23, 2007, 07:11 PM
1.4.2 API MouseListener (http://java.sun.com/j2se/1.4.2/docs/api/java/awt/event/MouseListener.html#mouseClicked(java.awt.event.MouseEvent))
Then you can use evt.getX() and .getY() to figure if its in the space you want.
~Hdx
Title: Re: How do I set just a specific area to trigger the actionPerformed() method?
Post by: Tomcat on June 14, 2007, 03:07 AM
Yeah, I figured it out. :-O  I just made a class... aww hell I haven't touched it in weeks, so I forget what I did, but it involved a separate class that was a JButton, or something like that.  Needless to say, it worked like a charm.  Email me at tomcat AT gdshadow DOT net if you've googled and come across this post and are wondering how to do this.  It's really simple, the kind of "shoot yourself in the foot" simple that makes you... well you know.