aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes SWT: missing a MouseListener method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "SWT: missing a MouseListener method" Watch "SWT: missing a MouseListener method" New topic
Author

SWT: missing a MouseListener method

manuel aldana
Ranch Hand

Joined: Dec 29, 2005
Posts: 308
hi,

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...

thnks.


aldana software engineering blog & .more
Mathias Nilsson
Ranch Hand

Joined: Aug 21, 2004
Posts: 367
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.

// Mathias


SCJP1.4
manuel aldana
Ranch Hand

Joined: Dec 29, 2005
Posts: 308
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.
manuel aldana
Ranch Hand

Joined: Dec 29, 2005
Posts: 308
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?

many thnx.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SWT: missing a MouseListener method
 
Similar Threads
Applet - Drag and Drop
Actionevent
mousePressed Problem
do click
MouseDragged event issue