Easy way to make resizable window?

Is there an easy way of making the display/context resizable?

With OpenGL (using LWJGL) I got it working by setting

before creating the display, and
[java]if (Display.wasResized() == true){glViewport(0,0,Display.getWidth(),Display.getHeight());}[/java]
just before Display.update(); in the main loop.

I’ve done some searching, and the only thing I’ve found that sounds like in the direction I want is this.

It’d be great if there was some way to accomplish resizing the window and view (while resizing UI at a locked aspect ratio) with jME, or with NiftyGUI somehow.

Thank you for help with this. I hope this is possible without needing to use Swing.

to have a resizable window you’ll need to run your game in canvas mode inside a jframe.

if you want your user interface to resize itself to fit the changing dimensions as it resizes you’ll need to override reshape(int,int) inside your SimeApplication and then pass that information to your appstate/s that handle your program’s gui.

unfortunately there isnt an easier way.

edit: fyi, if you use scene processors (like shadows, or filter post processor) i think theres a bug that causes them/some of them to cause scaling/stretching when resizing rather than the desired effect of maintaining the scene’s proportions. Only way I’ve found so far to prevent this is to just not adding scene processors when I want a re sizable window (haven’t gone too far in to investigating this though, just ran in to it the other day)

Ok, thank you. I’m quite new to all of this, Could you give me a bit more info on how I might do what you’re saying?

I’ve created a Jframe, and tried calling it with

[java]Jframe_main main_window = new Jframe_main();[/java]
Jframe_main being my Jframe class.
Which seems to do nothing (it continues to run, no warn or anything).

I’m not quite sure how to get the Jframe to display, let alone how to render the 3D world onto it. This is a niche sort of goal, and jMonkey is small so when I searched it not much relevant stuff came up (as said before, your thread did).

The only thing that jumps out at me is

[java] viewPort.attachScene(rootNode);

But I still don’t understand Java/jMonkey enough to know what is actually doing what (specifically rendering). I understand most of the basic logic, it’s when it comes to classes/constructors/methods is where I’m confused.

EDIT: I did find this in the wiki, but it’s a bit vaguely written on what goes where… oddly, that page is linked on this page despite one talking about nifty and the other talking about swing… unless they both can be used?

Doesn’t seem like something like resizing the window would be so complicated to do. Kinda frustrating, too, because 90% of games out there are like this and only allow for fixed resolutions, and not resizing the window properly (so you can’t have it maximized without fullscreen). Then there are games like Minecraft and Don’t Starve that just do it perfectly.

Of course, pretty much all regular applications work perfectly, too. But to be honest, I sort of want to make a regular application (basically a 3D modeling program) with jME…

In the example should be one that renders on a swing canvas, this is resizeable if i remember right.


that wiki page you found shows you how to make the canvas properly and add it to a jframe. theres also some examples inside of the jme tests project under jme3tests.awt (or something like that). you can create a duplicate of the tests project inside of the sdk when you do file->new project… you could probbaly use the test example as a “base” to start coding from or just copy and paste from it.