How to use OptionPanelState


public void loadGame() {
    getState(OptionPanelState.class).show("Load","load games",
            new CallMethodAction("Load saved game1", this, "instantAction")

When executed gets

nov 02, 2017 2:36:51 PM handleError
GRAVE: Uncaught exception thrown in Thread[jME3 Main,5,main]
java.lang.RuntimeException: Error invoking action method:loadGame
	at com.simsilica.lemur.CallMethodAction.execute(
	at com.simsilica.lemur.ActionButton$ClickCommand.execute(
	at com.simsilica.lemur.ActionButton$ClickCommand.execute(
	at com.simsilica.lemur.core.CommandMap.runCommands(
	at com.simsilica.lemur.Button.runClick(
	at com.simsilica.lemur.Button$ButtonMouseHandler.mouseButtonEvent(
	at com.simsilica.lemur.event.MouseEventControl.mouseButtonEvent(
	at com.simsilica.lemur.event.PickEventSession.buttonEvent(
	at com.simsilica.lemur.event.MouseAppState.dispatch(
	at com.simsilica.lemur.event.MouseAppState$MouseObserver.onMouseButtonEvent(
	at com.jme3.input.InputManager.processQueue(
	at com.jme3.input.InputManager.update(
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(
	at com.jme3.system.lwjgl.LwjglDisplay.runLoop(
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
	at java.lang.reflect.Method.invoke(
	at com.simsilica.lemur.CallMethodAction.execute(
	... 17 more
Caused by: java.lang.NullPointerException
	at com.pesegato.p8s.appstates.MainMenuAppState.loadGame(
	... 22 more

This can be avoided with this

getStateManager().attach(new OptionPanelState());

Which is a bit strange to me… However the button options don’t respond to mouse clicks.
I don’t know what I did wrong, please help!

Is returning null.

Because you can’t access a state unless you attach it, right?

Why is that strange? You have to attach an app state in order to access it, right?

How do you know?

I’ve checked “your” MainMenuState and I didn’t see the attach on your code, so I thought it wasn’t needed.

EDIT: I’ve seen it now :stuck_out_tongue:

I see the optionpane, but hovering with the mouse don’t highlight the options, and clicking on the options don’t do anything. The “CallMethodAction” isn’t executed here, but is executed on other buttons on the main menu

Which code? I have a lot of code.

99.99999999999999999999999999999999999999999999999999999999999% of my system-level app states like this will be attached in the application constructor like they should be.

And it uses the standard glass style? ie: highlighting won’t be screwed up for some other reason.

I’m not sure why it’s not working. Have you tried running my apps that use it to see if it still works there?

Sorry, I’ve seen it now.

Yes. I’ll try to build a self containted example and post. By the way, also “showError” has the same behavior

The self containted example works. So I did something wrong somewhere else… :expressionless:

Ah, the beauty and tyranny of the self-contained example. :slight_smile:

Here’s the bugged code:

public class HelloJME3 extends FullHDApplication {
    public static void main(String[] args){
        HelloJME3 app = new HelloJME3();
        app.start(); // start the game

    public void finalizeInit() {
                new OptionPanelState(),
                new MainMenuAppState());
        GuiGlobals globals = GuiGlobals.getInstance();

public abstract class FullHDApplication extends SimpleApplication {

    public static String TITLE;
    public static final String DISPLAY_VERSION = "December 17 beta";
    public static boolean COOKED_BUILD;
    public static String BUILD_REVISION;
    public static String BUILD_DATE;
    public Node scaledGuiNode = new Node("ScaledGUINode");
    public static Properties props = new Properties();

    BitmapText version;
    public static String defPath;

    static Logger log = LoggerFactory.getLogger(FullHDApplication.class);

    public static String mod = null;

    public FullHDApplication(AppState... appstates) {

    static void runApplication(FullHDApplication app, AppSettings settings) throws IOException {

    public void simpleInitApp() {
        float scalingFactor = Display.getWidth() / 1920f;
        version = new BitmapText(guiFont, false);
        version.setBox(new Rectangle(0, 0, Display.getWidth(), 215));
        version.setLocalTranslation(0, version.getLineHeight(), 1000);
        version.setText(DISPLAY_VERSION + "/" + BUILD_REVISION + "@" + BUILD_DATE);

    //if I comment the next line the error goes away!!!

    public abstract void finalizeInit();


It looks like that a Quad is hijacking the events!? But it’s not even registered…

I can’t explain it. If the text doesn’t have any listeners registered to it then it shouldn’t be messing with the picking.

Do you want a full working example to analyze?

Honestly, I barely have time to read the forum these days. Not sure when I’d get to look at it. If not the week of Thanksgiving then it wouldn’t be until Christmas.

It’s way easier for you to debug the issue locally, probably. Just look in the PickEventSession stuff… but it’s really only paying attention to things with listeners added.

I’ve noticed that the layout of the OptionPane don’t suit my needs, so I’ve resorted to adding a new Container. The Container don’t have the issue…

However, I’ll add a bug report on github, just in case…

OptionPanel is just a Container.

…which indicates that the issue is just random.

Are you implying that I cannot provide a code that reproduce the issue 100% of the times?

Challenge accepted.

Here you go OptionPane don't respond to input when adding a Quad · Issue #55 · jMonkeyEngine-Contributions/Lemur · GitHub

No, I’m implying that adding or not adding that BitmapText isn’t really the issue. Could be that if you added a second BitmapText then it would start working. Or if you added it first… etc…

It’s something probably unrelated to Lemur. Could be related to the empty node you have attached to the guiNode. Who knows?

Are you really sure?
To me, this looks like that the offending code shows an issue with either JME or Lemur (or LWJGL)… I do think that I’m using the APIs as they are intended, but feel free to prove me wrong.

The code posted on the Lemur issue tracker gets rid of the empty node and other unneeded stuff.

I’ve solved “my” issue because I realized that I don’t really need the OptionPane, so this probably will be my last post on this matter.

Yes, you are using the API correctly. I mean that it may be a bug in JME.

Lemur is not doing anything strange here. If those things are unclickable then it means that picking is messed up somewhere. Adding a BitmapText shouldn’t cause other collisions to fail.