Login  Register

Jglwindow focus challenges

Posted by imakerobots on Mar 19, 2015; 9:58pm
URL: https://forum.jogamp.org/Jglwindow-focus-challenges-tp4034169.html

Hi!

I have a split view with a jglpanel on the left and some swing components on the right.  

Stewart Platform Simulator

Some user actions create a modal dialog.  When the dialog would close focus would not return to the jglwindow.  I tried

        // focus not returning after modal dialog boxes
        // http://stackoverflow.com/questions/5150964/java-keylistener-does-not-listen-after-regaining-focus
        frame.addFocusListener(new FocusListener(){
            public void focusGained(FocusEvent e){
                //System.out.println("Focus GAINED:"+e);
            }
            public void focusLost(FocusEvent e){
                //System.out.println("Focus LOST:"+e);

                // FIX FOR GNOME/XWIN FOCUS BUG
                e.getComponent().requestFocus();
            }
        });

Which works fine ...until I put jtextfields in the right-hand view, and now I can't type in the fields because focus is jailed to the jglwindow all the time.  When I click on the jtextfield the cursor immediately disappears.

Please: What's the better way to solve this?

Thank you!

The code is here: https://github.com/MarginallyClever/rotarystewartplatform2

PW: WASDQE to fly around, RFTGYHUJIK to move the platform.  The goal is to make precision movements with the text fields and a "go" button.