This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
my aim is to get execute a listener method ONLY when following is happening: 1)a mouse button is pressed on a Button 2)this mouse button is released when it is still over the Button
unfortunately there are only three events for mouses like mouseUp mouseDown. if i use mouseUp() the event is fired too when i am pressing the button, exiting the button it and release the mouse button. this is different to usual gui behaviour so i don't wanna have that.
it would be cool if there was something like mouseClickedAndReleased or something...
mouseEntered(MouseEvent e) is invoked when the mouse enters a component. mouseExited(MouseEvent e) is Invoked when the mouse exits a component.
If you set a boolean value on the mouseEntered event and check the value in the mouseUp event. You must reset the value in the mouseExited event.
Joined: Dec 29, 2005
thanks, but i think you meant using Swing or AWT. i am using SWT from eclipse framework.
but anyway i found out the solution:
you have to add a widget-listener called MouseTrackListener and implement callback methods mouseEnter, mouseExit respectively.
Joined: Dec 29, 2005
hi, i've got a new problem regarding the same issue.
to achieve my goal (see first post) i added two mouse-listener to my button:
the problem now is: when i click on the Button and exit the button, the MouseTrackListener callbacks are not called, i.e. means in a way the buttonDown of MouseListener event blocks the MouseTrackListener callbacks.
i think that is because there is just one queue for all events. so it seems that when mouse button is pressed an event or callback blocks the whole UIThread so mouseExit() can not be called. but it is still weird that the mouseUp callback is called BEFORE the mouseExit() callback, though i exit the button before releasing the button.
so (if i am right with above assumption) how do i start a new thread for a listener?