How to get AppSettings on an AppState?

So, I was designing a GUI and decided to make it scale according to the current screen’s resolution. Upon doing that I realized that I couldn’t get the current AppSettings from a AppState. Is there a way to access it, or should I simply pass the AppSettings in the constructor?


AppSettings is a protected field of

but it provides no getter.
I think this is to prevent a class to change the settings during runtime.
I would pass the resolution as parameter to your Appstate

Well, you can write your own getter method in your extended SimpleApplication and when you create your app state use it as parameter.

Another way would be to write a class with static methods which care about setting graphic settings.

To apply your new graphic settings use main.refresh();

He just wants to read it therefore setting it is not needed/wanted

There is a reason that there is no getter included, so no one can mess up the settings

All right, if it’s only this, then he should do what you said.

I made a “settings changer” myself and there is / was no problem changing settings during runtime!

Do you just want to know the screen size? You don’t need app settings for that (and because it can be changed at runtime without updating the actual app it could lie to you, also).

Application.getCamera().getWidth() and getHeight().

Do you really want the “screen” (the full desktop), or rather the “display” (the area that is actually assigned to your application)? I guess you want the latter.
Then these method from lwjgl will help:


Using these may cause extra problems when migrating to newer JME versions. JME itself maybe hard to handle when upgrading, but that is another story. But if you just want to try JME with LWJGL 3, this doesn’t work.

…if you just want the size of your rendered display then that’s exactly what app.getCamera().getWidth() and app.getCamera().getHeight() will tell you. …which I already posted.

If you want to scale a UI, then those are the values you want. Not the ones in AppSettings.

Sorry for late reply, but thanks for your help guys! At the moment I pass the AppSettings to my AppState and simply get the width and height values. However, that doesn’t look “clean”, if you guys understand me. I’ll probably use @pspeed solution: to get the camera’s width and height.

But, If i mess with the camera’s frustum values, will those values remain the same?

@Pesegato what I need is the resolution the player chooses at start, when the jME settings dialog shows up.

Also, can’t this be changed? Most of games I know for PC (if not all of them) allow the user to change graphics options during runtime. I will implement this in my game, so wouldn’t be easier for AppStates to have access to the AppSettings, rather than creating new ones and applying them?

On a side note (and since this way I won’t need to create another thread), is it possible to make the jME window manually resizable? Like pushing the borders and/or allow to maximize the window?

I think app.restart() is what you’re looking for.

Camera width/height is the width of the display as JME sees it. The frustum affects the projection matrix but width/height don’t change unless the display size changes… which is what you want.

1 Like