Screen cleaning linked personal troubles

Hey, me gain, the pain in the **** guy :D.

This is very probably my fault, but I’ve looked everywhere I could think of without finding a solution.

The lil test class here should show you my problem and provide a way of testing solutions (at least for me :D).
Basically:

  • I initialize the screen
  • I add a window to the screen with a button
  • when I press the button, it tells me “first button was pressed” and then swaps the window (removes old window and adds the second window)
  • once the second window is displayed, I press “space bar”… which triggers the first button… an element removed from the screen

Very probably my error, but could you tell me what I should do more in the swapMethod so that glitch doesn’t happen, please?

[java]
import com.jme3.app.FlyCamAppState;
import com.jme3.app.SimpleApplication;
import com.jme3.input.event.MouseButtonEvent;
import com.jme3.math.Vector2f;
import com.jme3.renderer.RenderManager;
import java.util.logging.Level;
import java.util.logging.Logger;
import tonegod.gui.controls.buttons.ButtonAdapter;
import tonegod.gui.controls.windows.Window;
import tonegod.gui.core.Screen;

/**

  • test

  • @author jo
    */
    public class TestGuiCleaning extends SimpleApplication {

    private Screen screen;

    public static void main(String[] args) {
    TestGuiCleaning app = new TestGuiCleaning();
    app.start();
    }

    @Override
    public void simpleInitApp() {
    FlyCamAppState flyCamAppState = getStateManager().getState(FlyCamAppState.class);
    flyCamAppState.setEnabled(false);

     initScreen();
     firstScreen();
    

    }

    private void swapScreen(){
    screen.removeElement(screen.getElementById(“firstScreen”));
    secondScreen();
    }

    private void firstScreen(){
    Window window = new Window(screen, “firstScreen”, new Vector2f(100, 200));
    window.setText(“First Screen”);
    ButtonAdapter button = new ButtonAdapter(screen, “button01”, new Vector2f(20, 20)){
    @Override
    public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
    Logger.getLogger(TestGuiCleaning.class.getName()).log(Level.SEVERE, “First screen button pressed”);
    swapScreen();
    }
    };
    button.setText(“Click me”);
    window.addChild(button);
    screen.addElement(window);

    }

    private void secondScreen(){
    Window window = new Window(screen, “secondScreen”, new Vector2f(100, 200));
    window.setText(“Second Screen”);
    ButtonAdapter button = new ButtonAdapter(screen, “button02” ,new Vector2f(20, 20)){
    @Override
    public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
    Logger.getLogger(TestGuiCleaning.class.getName()).log(Level.SEVERE, “Second screen button pressed”);
    }
    };
    button.setText(“Click me”);
    window.addChild(button);
    screen.addElement(window);

    }

    private void initScreen() {
    screen = new Screen(this);
    // screen.initialize();
    getGuiNode().addControl(screen);
    screen.setUseToolTips(true);
    }

    @Override
    public void simpleUpdate(float tpf) {
    //TODO: add update code
    }

    @Override
    public void simpleRender(RenderManager rm) {
    //TODO: add render code
    }
    }
    [/java]

Hey you!

Thanks a bunch for the test case. Let me see what I can do with this today.

@loopies
I think I know how to resolve this. The tab focus should be cleared and I don’t think I’m doing this when something is removed/hidden.

Great thx :).

Only way around I found was to disable the button that triggers a window swap. Changing focus manually didn’t seem to work (or was used poorly by me).
Looked very hacky. But mostly, I was worried that stuff was lingering in the darkness of my ram :D.

Two unrelated notes:

  • v-sync is disabled (no more fps restriction) when I minimize the jme application… no idea if related to the gui or jme. The ventilators start working like crazy when I minimize.
  • the jme website projects/all projects finds no projects anymore so we can’t access your doc anymore.

Here is a direct link to the Wiki: (if this is documentation you were referring to)

Wiki

1 Like