GUI heavy 4x game

I’m developing a 4x game and because it relays a lot on GUI components and less on fancy graphics, I first started out just use plain java wit Swing. I created a galaxy map engine without the use of an engine by drawing everything on the Graphics2D object.
Nothing fancy but it works.

Now I am thinking on refactoring my game and rewrite it partially in JME so the galaxy map is proper 3D.

The thing I haven’t figured out is what do I do with my GUI. I know I could use nifty GUI but currently my entire GUI is written in Swing. I use a lot of the typical Swing components like tables, trees and so on.
Any tips on what I should do with my GUI would be helpful.

Is it targeted for desktop? Is java 1.8 dependency ok?
Then i have a solution for you.

JavaFx has a swingpanel, where you can directly reuse swing stuff.
It should mostly work out of the box.

Yes it’s desktop.

Thanks for the link. That solution seems great. I’ll have a look at it.


before i forget, another solution might be to use jme in swing.

Depends on what your needs are.

1 Like

That’s also really helpful :slight_smile:

What would be the best solution for a 4x game?

I basically have a galaxy view where you navigate using click and drag. This is the main view of the game.
You interact with the objects in the galaxy like stars and ships and so on. Right clicking will open a context menu with actions.
Each window to manage your planet, fleet, colony or what ever is a complex UI with tables, trees, and so on.

The JME3 Canvas seems better at first sight because that’ an out of the box solution while the JavaFX solution is a workaround to get Swing working inside JME.

It depends on what your target is. (really this is something you should decide based on your preferences, i can just dump a few thoughts here):

basically jme in swing involves a copy of the 3d output to swing.
jfx in jme copies the jfx output to jme for use as a texture.

If swing, the 3d view cannot be updated
if jfx lags the ui simply updates more sluggish, the 3d viw is not affected.
however if the 3d view lags, the swing ui stays responsible while the jfx ui does not.
-> Depends on where your main focus is better responsive ui or better responsive 3d view?

If you plan on styling your ui, jfx is in the long run better, as it has css support, also it has the very great scenebuilder.
(as jfx it was designed with this in mind it also does work and is not crappy like the swing ones, its like the ui binder from gwt)
Using jfx would allow you to slowly update your components, and reuse them without having to do all at once.

I’m not to sure how good swing handles jme, as jme might be a heavyweight component.
anyway for swing there is a JFXPanel, wich does jfx in Swing, so that direction would also allow slow replacing of ui parts and using most of jfx features.

Your options to embeded jme into swing are : jme3 canvas, jme3 AWTPanel and jme3_ext_swing. I created jme3_ext_swing because a user has some issue with other solution, see the discussion). jme3_ext_swing is a JPanel where other are Canvas (including AWTPanel).

About integration with javafx, you can do jme into javafx and javafx into jme.
For a game, IMHO javafx is far better than swing, you can style the display via css, use custom font easily,… have some simple effect (shadow, glow, …). (see a simple game I made in 48H)

DISCLAIMER: I’m also a contributor to jme3-jfx