Fullscreen in game

sorry i noob at game dev…

now i want to create fullscreen in my game.

but in option setting

first my game is in windows mode… and when i go to option setting i want to change to fullscreen

but

in global variable

[java]

static AppSettings a;

Main app;

[/java]

when i try this in update



[java]

a.setFullscreen(true);

app.setSettings(a);

[/java]



but it’s error…any body can help me??



sory my english is bad… thanks before:D

“It’s error” is not very descriptive, post the error output. You probably try to set a screen resolution that the graphics system doesn’t support. You have to check what resolutions are supported first. The SettingsDialog does it this way:

[java]

GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();

modes = device.getDisplayModes();

[/java]

the error code : null pointer exaction…

the resolution is from 800x600 to fullscreen



the simple code maybe like this



[java]



public class Main extends SimpleApplication {



Main app ;

static AppSettings a;



public static void main(String[] args) {

Main app = new Main();

a = new AppSettings(true);

a.setFullscreen(false);

app.setSettings(a);

app.setShowSettings(false);

a.setWidth(800);

a.setHeight(600);

app.start();

}

}

[/java]







at update i change like this (when 1click a image)



[java]

a.setFullscreen(true);

app.setSettings(a);

[/java]



the error code is like this



eror code like this

[java]

java.lang.NullPointerException

at mygame.Main$1.onAction(Main.java:146)

at com.jme3.input.InputManager.invokeActions(InputManager.java:143)

at com.jme3.input.InputManager.onMouseButtonEventQueued(InputManager.java:363)

at com.jme3.input.InputManager.processQueue(InputManager.java:565)

at com.jme3.input.InputManager.update(InputManager.java:600)

at com.jme3.app.Application.update(Application.java:453)

at com.jme3.app.SimpleApplication.update(SimpleApplication.java:223)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:158)

at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:203)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:221)

at java.lang.Thread.run(Thread.java:619)

[/java]



sorry my english is bad… and thanks for help :smiley:

Dude, the error is in your own code, Main.java, line 143, one of your objects is null… :roll: This is probably the most basic error stack trace you’ll ever encounter. Its only gonna get harder from here on so I suggest you try and make sense of the error output and read up a bit more on writing / compiling / debugging java applications in general so you can solve these kinds of small problems (that happen to any programmer) yourself.

thanks 4 help.:smiley:

i just forget to app.restart :D…thanks

i have put app.restart();

but it still doesn’t work. and the error same like yours. can you help me?

@sist said:
i have put app.restart();
but it still doesn't work. and the error same like yours. can you help me?


You haven't provided enough information.

public class Main extends SimpleApplication{

Main app;

static AppSettings as;



public static void main(String[] args) {

Main app = new Main();

app.setShowSettings(false);

as = new AppSettings(true);

as.setTitle(“Crazy Game”);

as.setFullscreen(false);

app.setSettings(as);

app.start();

}



and the code when i click the image

as.setFullscreen(true);

app.setSettings(as);

app.restart();



and it still error. can you help me?thx…

This:

java.lang.NullPointerException

at mygame.Main$1.onAction(Main.java:146)



Was a null pointer in YOUR code. But I can’t see that code. I don’t know what line 146 (or whatever other line it is now) is. On that line, you have a reference to an object that you haven’t set to anything and you are trying to do something with it.

the error is in the bold one

as.setFullscreen(true);

app.setSettings(as);

app.restart();



but actually in my code as in static AppSettings as; is italic. is it problem or not?thx

@sist said:
the error is in the bold one
as.setFullscreen(true);
app.setSettings(as);
app.restart();

but actually in my code as in static AppSettings as; is italic. is it problem or not?thx


The answer is "ven't set th". I will provide the beginning and end when you give us a wider-than-three-lines view of the problem. ;)

Actually, I can see enough to tell you 100% for sure that "app" is null. I just can't see enough to tell you how to fix it because you are doing strange things and I don't see why.

a) you are resurrecting an 8+ year old thread. b) the NullPointerException was in the application’s code and is unrelated to that other thread.

1 Like

That makes sense. But this post is too old, most likely everything discussed here is outdated.
Replying to old posts put them back at the top of the forum causing more confusion than anything.

1 Like

Wrapping up this thread for any potential future resurrecters, if an NPE happens right on that line then ‘app’ is null and the problem is not a JME problem.

1 Like