Re: Mouse Events not being registered
From: Tom N (tom_at_nospam.au)
Date: 02/24/04
- Next message: Tom N: "Re: Mouse Events not being registered"
- Previous message: hiwa: "Re: New to OOP and polymorphism"
- In reply to: John Champaign: "Mouse Events not being registered"
- Next in thread: Tom N: "Re: Mouse Events not being registered"
- Reply: Tom N: "Re: Mouse Events not being registered"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 24 Feb 2004 02:32:34 GMT
I tried a button next to a label, both with mouse listeners and an action on
the button.
If you press the mouse down outside the button (in the label in my code),
than drag the mouse into the button and release it, then the mouseReleased
event goes to the same place as the mousePressed event went (i.e. the
label - where you pressed the mouse button, not where you released it).
This seems to preclude simpling adding a mouse listener on the button that
listens for mouse pressed and mouse released.
I also tried a mouse listener on the panel and it behaves in exactly the
same way as the label (i.e. the mouse released event goes to the panel if
the mouse pressed event went to the panel).
However the following seems to do what you want
"The Glass Pane
If you make the glass pane visible, then it's like a *** of glass over all
the other parts of the root pane. It's completely transparent unless you
implement the glass pane's paintComponent method so that it does something,
and it intercepts input events for the root pane.
The glass pane is useful when you want to be able to catch events or paint
over an area that already contains one or more components. For example, you
can deactivate mouse events for a multi-component region by having the glass
pane intercept the events. Or you can display an image over multiple
components using the glass pane."
http://java.sun.com/docs/books/tutorial/uiswing/components/rootpane.html
"John Champaign" wrote:
> I'm working on an educational applet for a child with special needs.
>
> He's got a bit of a trick to make my life more difficult... To interact
> with the applet he needs to click on buttons, which is fine most of the
> time (he comes from a Mac environment, so I accept mouse clicks from the
> right or left button when he's working on the PC). But every once in a
> while, he'll press and hold the right mouse button, move onto a JButton,
> then left-click, which my applet doesn't seem to like (it doesn't
> register that the mouse has been clicked).
>
> My *GUESS* of what the problem is is that the mouse event begins when he
> is off the JButton, so its not registered with the JButton's mouse
> listener (although the Panel it begins on isn't a mouse listener).
> When he moves onto the JButton and clicks the new "Mouse Presed" event
> isn't passed to the JButton's listener. This doesn't make complete sense
> as the JButton DOES detect when the cursor moves on or off the JButton (so
> its still registering *some* new mouse events).
>
> The only way I currently see around this is to make the Panel the button
> was added to a mouse listener, then pass clicks to the appropriate buttons
> depending on the cursor's location. Does anyone have any ideas for a
> cleaner way to fix this? The user is non-verbal, so telling him not to do
> this isn't an option.
>
> My apologies for the lengthy explaination. I've searched for this, but
> couldn't find anyone experiencing something similar. If you have any
> suggestions for search terms that I might have missed (my apologies in
> advance), I'd love to hear them.
- Next message: Tom N: "Re: Mouse Events not being registered"
- Previous message: hiwa: "Re: New to OOP and polymorphism"
- In reply to: John Champaign: "Mouse Events not being registered"
- Next in thread: Tom N: "Re: Mouse Events not being registered"
- Reply: Tom N: "Re: Mouse Events not being registered"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]