For a number of reasons, I wish to handle input events myself in a CAD-type of system, without the ordinary generated objects like MouseEvent, KeyEvent, etc.
First, the stream of object creations incurs a fair amount of overhead, particularly for mousemoves.
Second, the arbitrary division between keyboard and different kinds of mouse events only makes it harder to uniformly process events. By the time I’m done, I’ve coalesced all the relevant information anyway regardless of which kind of event it was, so it is only increasing the amount of code.
My Viewer class extends from JPanel, and overriding processEvent gets a single event. the resize when I first start up, then nothing. I know there are problems playing nicely with swing, is the solution to use Frame and Panel instead? Inside my viewer is a GLCanvas. I will try to subclass that next, but I would hope that I can make the parent intercept the child’s events in any case, because of an annoying problem – the GLCanvas isn’t getting the focus and I have to click into it, despite the fact that there is nothing else in the window.
So to sum up, I have a JFrame, inside it a JPanel, and inside that a GLCanvas. Is there any convenient way to:
- intercept the events BEFORE they create those AWT events in a single routine (Swing must do it somewhere).
- Make the GLCanvas have the focus without clicking in.