• Post Reply Bookmark Topic Watch Topic
  • New Topic

Triggering an AWT event

 
Jody Seigle
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to figure out to trigger a MouseReleased event for a
given component. Such as the following code:
<CODE>
public void mouseDragged( MouseEvent e)
{
if (something)
{
e.getComponent().'fireMouseReleasedEvent'();
}
}
</CODE>
Thanks.
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Jody -
AWT Components don't expose their dispatch or 'firing' methods. Those methods are encapsulated to insure a program can't arbitrarily fire events for a given component. java.awt.Button, for example, only fires an ActionEvent when the Button itself is clicked/pushed. You'd have to look at the source code in most cases to learn how the dispatch is invoked, and even then all you'd have is the knowledge of how it's done.
In your example, you're getting a reference to the source component and trying to make it fire a second time. I'm pretty sure that's not really your intent. Could you give more flesh to your example?
------------------
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide
 
Jody Seigle
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My exact problem is this. When a component is being dragged I need to validate it's position and if the position fails validation then I need to have the 'handle' on the component drop. (ie. A mouse released event). Meaning if the component is going to be dragged again the user would have to reclick on the component and drag it again. I thought I could just call the mouseReleased method but I was also wondering if AWT has listeners of its own that handle causing the mouse to lose it's focus on the component, change the cursor, etc.
Looking through the API, I saw the processMouseEvent method. Does this method even come close to doing what I need?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!