Nifty checkboxes with weird display

on my current programm I had added checkboxes to my Nifty gui. Also the documemtation was a little rare, it finaly seems to work. But there are sometimes issues by displaying. Normaly the boxes appears round, have a mouse hover and display which box from the group is selected. On aproximatley every third or fourth start they are disolayed with a aquare shape and no hover. None gets displayed as marked, when clicked, but the java controller is able to requst which one is active. As I mentionend the docu was rare and its possibly that I missed something.

I’ve use Nifty checkboxes quite a bit and haven’t seen this issue. The shapes of Nifty controls (such as checkboxes) are determined by style resources stored on the classpath. If you use “nifty-controls-style-black” (which is the default) then checkboxes should be square. The default style uses round shapes for radio buttons, I think.

Is there any possibility that the classpath changes from run to run?

I don’t hope so. Butt I import multiple style xmls. Could it be that they disturb each other and with the styles in jar?

1 Like

sorry cant use the normal braces in this thread

[useStyles filename=“nifty-default-styles.xml”/]
[useControls filename=“nifty-default-controls.xml”/]
[useStyles filename=“Interface/nifty-textfield.xml” /]
[useStyles filename=“Interface/nifty-button.xml” /]

  <inCodeBlocks />
  1. Are there any warning messages during startup?

  2. I’m curious why you are importing multiple styles. What is that meant to achieve?

To answer your question, I don’t see how multiple styles could cause different behavior from run to run. A race condition seems more plausible.

<it works, thanks>

the reason why I’m importing all this styles is very simple: on my first game with jme I had a lot of try & error because I couldn’t find so much documentation for nifty. On the second game i thought I simply copy the nifty files from my first game and just add some checkboxes. But it not seems to be that simple.

When an application uses more than one Nifty screen, I found it works best to load the controls and styles from Java instead of from XML.

On start: I would prefer this too, but the Nifty documentation mentioned that the xml way is better documentated and because I always write small programs, I don’t run in the problem of having to much Nifty screens.

As I recall, pure XML works OK for a single-screen apps. For multiple-screen apps, I stopped using that approach in 2018.

I still lay out each screen and popup in an XML document, but instead of including

<useStyles filename="nifty-default-styles.xml"/>
<useControls filename="nifty-default-controls.xml"/>

in each document, I parse and process the styles and controls using Java:


prior to loading any screens or popups. I wonder if this approach might solve your issue.

If the documentation recommends otherwise, perhaps it is out of date.

Just curious: which documentation are you using?

There was something put out called the ‘nifty bible’ or something. I’m not familiar with it because it came out long after I gave up on nifty and switched to something else… but I’ve heard other folks claim it is very helpful.

If that’s already what you are using then this information isn’t useful.

Yep, still valid for 1.4.3. You absolutely need it for unravel Nifty.

1 Like

yes, this is what I mentioned, when I’ve written docu is rare on checkboxes: I’ve found this file, because it is still linked on the jme site abaut creating gui for JMonkey. Its explains good how to start and do your first screens, but when you search espacelly for checkboxes you got just 2 findings. And when I googelt for examples wit checkboxes, I’ve found just enough to insert button groups and bring the boxes to work.
On my first project the problem was, that I first built the game and then was looking fo a simple gui. And the problem was to intigrate Nifty in my game and because I had already init a Skybox to the rootNode before the position I tried to add Nifty, so I had make me a lot of trouble for myself.

@tonhele excuse me, also this answer, I thank you of trying to helping me.

No problem. If you need any further examples. Our project OpenKeeper at Github, is using Nifty, a lot.

1 Like

thank you, i will remember that if I got my next problem!

I removed the useStyles elements for textfield and bottom. Now it seems ok when running on desktop. Its only gets still wered on android, when I change the device orientation while the checkboxes are shown.