Style Warnings Problem [Solved]

Hi guys, I’m back with another problem I’m facing with nifty gui. I don’t know exactly what is causing it, but when I load my xml files it seems that there are a bunch of warnings that get displayed in the console saying that I have already loaded a certain style. I think all this repeated loading of styles is causing my gui to load much much slower than it normally would (which is causing some bugs). Here is one xml file I use in my gui.

<?xml version="1.0" encoding="UTF-8"?>

<nifty xmlns="" xmlns:xsi="" xsi:schemaLocation="">
    <useControls filename="nifty-default-controls.xml"/>
    <useStyles filename="nifty-default-styles.xml"/>
    <screen id="GScreen0" controller="Controller.OptionChooserController">
        <layer id="GLayer0" childLayout="center">
            <panel id="GPanel0" childLayout="absolute" backgroundImage="Images/Background/generalOptionsBackground.png" width="300" x="0" y="0" height="400">
                <text font="Fonts/Default.fnt" color="#ffff" text="Options" x="120" y="10%"/>
                <control name="button" id="currentSceneButton" label="Current Scene" x="88" y="20%" width = "125" height="20"/>
                <control name="button" id="newSceneButton" label="New Scene" x="88" y="30%" width="125" height="20"/>
                <control name="button" id="cameraButton" label="Camera" x="88" y="40%" width="125" height="20"/>

But for some reason my console is saying I have loaded some styles already even though this is the first xml file I load in my program.

Jun 26, 2017 5:28:36 AM de.lessvoid.nifty.Nifty registerStyle
WARNING: Style: nifty-panel was already registered. The new definition will override the previous.
Jun 26, 2017 5:28:36 AM de.lessvoid.nifty.Nifty registerStyle
WARNING: Style: nifty-panel-red was already registered. The new definition will override the previous.
Jun 26, 2017 5:28:36 AM de.lessvoid.nifty.Nifty registerStyle
WARNING: Style: nifty-panel-no-shadow was already registered. The new definition will override the previous.
Jun 26, 2017 5:28:36 AM de.lessvoid.nifty.Nifty registerStyle
WARNING: Style: nifty-panel-red-no-shadow was already registered. The new definition will override the previous.
Jun 26, 2017 5:28:36 AM de.lessvoid.nifty.Nifty registerStyle
WARNING: Style: nifty-panel-simple was already registered. The new definition will override the previous.
Jun 26, 2017 5:28:36 AM de.lessvoid.nifty.Nifty registerStyle
WARNING: Style: nifty-panel-bright was already registered. The new definition will override the previous.

I don’t know if this is even the xml files fault or if it has to do with something else. This is one of my smaller files also, the larger ones I have spit out about 7x the amount of warnings about already registered styles…
Does anyone know where I am registering styles repeatedly?
Thanks for the help. :slight_smile:


We would need to see your code to answer this question. Code you post it here please?

1 Like

I believe some of these warnings are caused by a known issue with NiftyGUI:

1 Like

I see what you are saying sgold. I have nifty control styles black jar which should be the fixed jar so I don’t think that is the issue but I do think the issue revolves around my jar files because I’ve had some trouble getting them to work right in the past. Anyways Ill post some code about how I go about creating my gui. For starters just so my code makes a little more sense is that I have multiple scenes in different xml files just for organization and have a seperate controller for each one. I also have a helper class just to switch scenes between these files easily.

Here is the code (relating to my gui) I have in my applications simpleInitApp method


I have a few more methods in the Main class

private static void initGUI() {
        System.out.println("Started init GUI");
        display = new NiftyJmeDisplay(Main.application.getAssetManager(), Main.application.inputManager, Main.application.audioRenderer, Main.application.guiViewPort);
        nifty = display.getNifty();

public static void addGUI() {
public static void removeGUI() {

and here is my helper class…

 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
package mygame;

import Controller.CameraOptionsController;
import Controller.GasSceneOptionsController;
import Controller.NewSceneOptionsController;

 * @author Cats
public class GuiHandler {
    static AbstractAppState pausedAppState;
    public static void openGUI() {
    public static <T extends AbstractAppState>  void openGUI(T appState) {
        pausedAppState = appState;
    public static void goToSceneOptionsGasGUI() {
        Main.nifty.fromXml("GUI/SceneOptionsGasGUI.xml", "GScreen0", new GasSceneOptionsController());
    public static void goToOptionChooserGUI() {
        Main.nifty.fromXml("GUI/OptionChooserGUI.xml", "GScreen0", new GasSceneOptionsController());
    public static void goToNewSceneOptionsGUI() {
        Main.nifty.fromXml("GUI/NewSceneOptionsGUI.xml", "GScreen0", new NewSceneOptionsController());
    public static void goToCameraOptionsGUI() {
        Main.nifty.fromXml("GUI/CameraOptionsGUI.xml", "GScreen0", new CameraOptionsController());
    public static void closeGUI() {
        if (pausedAppState != null) pausedAppState.setEnabled(true);

Now the reason that I call Main.addGUI() every time I add the the gui to the screen is because I was running into a problem where if I just re added the display to application you would be able to see the previous scene that was loaded for a brief instant before it went to the scene I wanted it to. However if I do this I end up getting multiple calls to my niftyeventsubscriber methods when I open up the gui more than once, which is obviously a problem. The reason I asked this warning question was because I am hoping that the warnings are causing my scenes to load slower and are causing that previous scene to be visible for a brief instant. However, if this is not the case and there is some other problem causing this it would be appreciated if you could point me in the right direction of what to fix. Because of this I it is not essential for the warnings problem to be solved but I do want it to be.
Thanks for the responses thus far :slight_smile:

1 Like

If you’ve ruled out NiftyGUI issue #384 (and I remain unconvinced) then the next likely cause for “already registered” warnings would be multiple XML files, each containing the same <useStyles> tag. You mentioned that you have an XML for each scene. Presumably each one has a tag for “nifty-default-styles.xml” or whatever styles you use. This can generate lots of warnings when the 2nd and successive XML files are parsed.

In my Maud editor (which uses XML) I disable the warnings while loading XML files, like so:

         * Load the Nifty XML for generic popups.  For some reason the
         * assets do not validate, so skip validation.
         * Also, mute the warnings about re-registering styles.
        Logger niftyLogger = Logger.getLogger(Nifty.class.getName());
        Level save = niftyLogger.getLevel();
1 Like

You were right about pretty much everything you posted sgold. I have not really used git hub before so I thought I downloaded the latest version but I did not because issue 384 wasn’t in an actual release. When I actually got the latest version it stopped allot of my warnings and I also did have the useStyles tag in my different xml files. I also had some custom styles with the same name in my xml files because I thought they would only apply to those xml files. As I hoped this pretty much speed up the scene switching portion in my gui so you can no longer see the old scene when the gui is opened again. Thank you so much for your help.


I’m glad I was able to help.

The Nifty GUI JARs in JME 3.1’s jme3-niftygui library are from Nifty GUI 1.4.2 release, which is now over 14 months old. I’m not aware of any more recent releases. Since you said “latest version”, I’m guessing you built your own JARs from the sources on GitHub. Is that right?

1 Like

Exactly right.


For anyone coming from google I resolved this by putting this in my initialization code

    Logger.getLogger("de.lessvoid.nifty.Nifty").setFilter(new Filter(){
        public boolean isLoggable(LogRecord lr) {
            boolean isReregisterMessage = lr.getMessage().contains("The new definition will override the previous.");
            return !isReregisterMessage;

This way I suppress the noise while retaining any important log messages

I think I could also get rid of the warnings by only having the in one xml file, but that feels nasty, should the load order really matter? (I assume the first one needs the useStyles and the rest technically don’t)