So, the application situation is:
A complex Swing application with Xith3D running in an embedded JPanel. Currently the mouse input and control in the JPanel is handled by a Swing MouseAdapter because when I switched to Swing instead of AWT, the xith input system stopped receiving events.
I would like to add xith HUD objects to the view as well, for zoom and rotate buttons similar to google earth. However, since I am not using the xith input system, I'm unsure how to pass mouse events into the HUD to interact with those elements. In my quick survey of the HUD class, all of the mouse handling callbacks are private methods.
Is there something extra setup needed to use the xith input system with a Swing panel? I tested it in one of the xith-tk tests, and with exactly the same setup code it works properly with the AWT panel and fails with the swing.
From a slightly modified HUDConsoleTest2.java:
public HUDConsoleTest2( BasicApplicationArguments arguments ) throws Throwable
{
super( arguments.getMaxFPS() );
Xith3DEnvironment env = new Xith3DEnvironment( this );
ResourceLocator resLoc = TestUtils.createResourceLocator();
resLoc.createAndAddTSL( "textures" );
createHUD( env, arguments.getResolution() );
Canvas3DJPanel canvas = new Canvas3DJPanel(new CanvasConstructionInfo( OpenGLLayer.JOGL_AWT, DisplayMode.WINDOWED, true, FSAA.ON_2X, "3D View" ));
env.addCanvas( canvas );
canvas.getCanvas().addWindowClosingListener( new WindowClosingRenderLoopEnder( this ) );
this.addFPSListener( new CanvasFPSListener( canvas.getCanvas() ) );
InputSystem.getInstance().registerNewKeyboardAndMouse( canvas.getCanvas().getPeer() );
// Frame window = new();
JFrame window = new JFrame();
window.setSize(800, 600);
window.add(canvas);
window.setVisible(true);
}
That code will set up the input system and work fine, allowing you to drag the HUD around. Changing the OpenGLLayer to OpenGLLayer.JOGL_SWING will still show the HUD, but all input is now ignored.
Any suggestions on where to start? I need a way to either call the HUD mouse handlers from the Swing inputhandler, or to connect the xith inputhandlers so they work when used in a swing environment.
Thanks,
-Mike Ford