
Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/
>> at the end of my post is an example where I try to consume() the mouse
>> event, when the click in a button is in the right part of it. When the
>> click is in the left part, nothing is done and the button shall get
>> pressed.
>
> You example code does not compile. Please make sure it does before posting.
(Tried it :-) Compiles on my machine right now... What went wrong on yours?)
> However, the problem is that consume is relevant only before the
> listeners are fired. Even if it did succeed, would you be sure that your
> listener was called before the UI delegate's listener?
>
> Also mouse pressed, IIRC, is used to arm the button. Mouse clicked is
> used to fire the action event (assuming already armed).
Those questions bounced through my head, because listeners just smell
like that...
> The obvious thing to do is override JComponent.contains.
Well, indeed. My brain... I came across that a few weeks ago.
Thanks a lot for your quick reply.
Best wishes,
Rainer

Signature
Rainer Schwarze (Mr.) -- remove .nospam for email
Thomas Hawtin - 22 Aug 2005 18:41 GMT
>> You example code does not compile. Please make sure it does before
>> posting.
>
> (Tried it :-) Compiles on my machine right now... What went wrong on
> yours?)
Mea culpa. I should follow my own advice... I read it and decided that
JButtonX (not a good name for a class btw) didn't exist. I didn't expect
some code that had absolutely no reason to extend a class to be in an
inner class.
>> However, the problem is that consume is relevant only before the
>> listeners are fired. Even if it did succeed, would you be sure that
[quoted text clipped - 5 lines]
> Those questions bounced through my head, because listeners just smell
> like that...
The action event from a JButton is fired in response to input listeners,
for instance MouseListener. Even if you manage to stop an event firing
mid way through (for instance by throwing an exception), you don't
necessarily know the order in which the listeners are firing. So whether
the action event has already fired or not is uncertain.
Tom Hawtin

Signature
Unemployed English Java programmer
http://jroller.com/page/tackline/