Clicking TextField causes exception

I have a nifty gui screen that works perfectly, except whenever I click on the TextField (I have only one) I get the following exception:

[java]Feb 06, 2013 2:02:05 PM de.lessvoid.nifty.NiftyMethodInvoker callMethod
WARNING: RuntimeException: java.lang.IllegalArgumentException: wrong number of arguments
Feb 06, 2013 2:02:05 PM de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: sun.reflect.NativeMethodAccessorImpl invoke0 (NativeMethodAccessorImpl.java:-2)
Feb 06, 2013 2:02:05 PM de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: sun.reflect.NativeMethodAccessorImpl invoke (NativeMethodAccessorImpl.java:57)
Feb 06, 2013 2:02:05 PM de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: sun.reflect.DelegatingMethodAccessorImpl invoke (DelegatingMethodAccessorImpl.java:43)
Feb 06, 2013 2:02:05 PM de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: java.lang.reflect.Method invoke (Method.java:601)
Feb 06, 2013 2:02:05 PM de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: de.lessvoid.nifty.NiftyMethodInvoker callMethod (NiftyMethodInvoker.java:145)
Feb 06, 2013 2:02:05 PM de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: de.lessvoid.nifty.NiftyMethodInvoker performInvoke (NiftyMethodInvoker.java:104)
Feb 06, 2013 2:02:05 PM de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: de.lessvoid.nifty.Nifty$DelayedMethodInvoke perform (Nifty.java:1176)
Feb 06, 2013 2:02:05 PM de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: de.lessvoid.nifty.Nifty invokeMethods (Nifty.java:1154)
Feb 06, 2013 2:02:05 PM de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: de.lessvoid.nifty.Nifty handleDynamicElements (Nifty.java:312)
Feb 06, 2013 2:02:05 PM de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: de.lessvoid.nifty.Nifty access$1500 (Nifty.java:73)
Feb 06, 2013 2:02:05 PM de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: de.lessvoid.nifty.Nifty$NiftyInputConsumerImpl processEvent (Nifty.java:1371)
Feb 06, 2013 2:02:05 PM de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: de.lessvoid.nifty.Nifty$NiftyInputConsumerImpl processMouseEvent (Nifty.java:1329)
Feb 06, 2013 2:02:05 PM de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: com.jme3.niftygui.InputSystemJme handleMouseEvent (InputSystemJme.java:124)
Feb 06, 2013 2:02:05 PM de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: com.jme3.niftygui.InputSystemJme onMouseButtonEventQueued (InputSystemJme.java:196)
Feb 06, 2013 2:02:05 PM de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: com.jme3.niftygui.InputSystemJme forwardEvents (InputSystemJme.java:260)
Feb 06, 2013 2:02:05 PM de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: de.lessvoid.nifty.Nifty update (Nifty.java:248)
Feb 06, 2013 2:02:05 PM de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: com.jme3.niftygui.InputSystemJme endInput (InputSystemJme.java:113)
Feb 06, 2013 2:02:05 PM de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: com.jme3.input.InputManager processQueue (InputManager.java:821)
Feb 06, 2013 2:02:05 PM de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: com.jme3.input.InputManager update (InputManager.java:885)
Feb 06, 2013 2:02:05 PM de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: com.jme3.app.Application update (Application.java:606)
Feb 06, 2013 2:02:05 PM de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: com.jme3.app.SimpleApplication update (SimpleApplication.java:230)
Feb 06, 2013 2:02:05 PM de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: com.jme3.system.lwjgl.LwjglAbstractDisplay runLoop (LwjglAbstractDisplay.java:151)
Feb 06, 2013 2:02:05 PM de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: com.jme3.system.lwjgl.LwjglDisplay runLoop (LwjglDisplay.java:185)
Feb 06, 2013 2:02:05 PM de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: com.jme3.system.lwjgl.LwjglAbstractDisplay run (LwjglAbstractDisplay.java:228)
Feb 06, 2013 2:02:05 PM de.lessvoid.nifty.NiftyMethodInvoker logException
WARNING: java.lang.Thread run (Thread.java:722)[/java]

It doesn’t crash the program, or even the nifty gui, it just logs the message in console. I have attempted multiple TextFields, and they all generate the exception on click. I do not have an “onClick” event on my TextField, but I tried adding one. The event performs fine, but the exception still logs in the console. I attempted moving the TextField onto a different panel and layer but it still generates the exception. I also tried to add visibleToMouse true and false, but neither affects the exception. It’s probably something simple I’m missing, but I can’t find much on this exception through Google.

It only happens for the left mouse button click, but doesn’t matter if the TextField had focus before or not.

Thanks in advance for any help!!

Nifty doesn’t crash, or rather very rarely do. Instead, it spews warnings like the above.

From my experience with Nifty the above is not the complete text it dumped on you, so read each line until you find one that looks where you were working your last edit and it might (hopefully) be at this point where the error is.

I’ll admit that the “Wrong number of argument” sounds like a good candidate but there isn’t enough info to get where it’s coming from.

Thank you very much for the quick response.

That’s the weird thing, that is the entirety of the message in the jme3 output. Normally when I get a nifty exception, I can search for “root” and find the line in my java that’s causing the error, but not so with this error. None of the lines of the exception reference anything in my code, they’re all lwjgl, or nifty.

Here are the relevant parts of my xml file, am I missing something in there? Thanks again!
[java]

<?xml version=“1.0” encoding=“UTF-8”?>
<nifty xmlns=“http://nifty-gui.sourceforge.net/nifty-1.3.xsd” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=“http://nifty-gui.sourceforge.net/nifty-1.3.xsd http://nifty-gui.sourceforge.net/nifty-1.3.xsd”>
<useStyles filename=“nifty-default-styles.xml” />
<useControls filename=“nifty-default-controls.xml” />

<screen id=“mainScreen” controller=“com.company.package.NiftyOptionsManager”>

<layer id=“optionsPanelLayer” halign=“left” width=“100%” height=“95%” childLayout=“vertical”>
<panel id=“optMainPanel” name=“panel” height=“100%” width=“200px” align=“left” valign=“top” style=“nifty-panel-no-shadow” childLayout=“vertical” visibleToMouse=“true” padding=“2px” >

<control name=“textfield” id=“itemNum” maxLength=“20” visibleToMouse=“true”/>

</panel>

</layer>
</screen>
</nifty>

[/java]

Eyeballing it says it’s ok.

You can try using nifty.validateXml(“some_path/screens_xml.xml”); and see what kind (if any) of error you get.

That’s all I can offer honestly. Using Nifty is an exercise in patience. Either you get some or you flip tables. Possibly both.

It probably means that a callback method somewhere has the wrong number of paramaters (i.e. expecint blah(int x, int y), instead got blah()).

Check all your callbacks, also make sure your nifty and nifty-controls jar as matching versions, etc.

Thank you both for your help. I went about it another way, without using a text field. I will update if I revisit this feature. Thanks again!

I had a similar issue today, and found a solution. (Not on a textfield, but a custom button)

In my XML i had the following interacts setup:
[java]
<interact onPrimaryRelease=“onButtonReleased()” onPrimaryClick=“onButtonClicked()” />
[/java]

I found that the last one "onPrimaryClick=“onButtonClicked()” was causing the issue, my guess is that .onButtonClicked() is already used internally in Nifty, but with arguments, causing it to attempt to call the method in nifty instead of the one inside my Controller, explaining the [java]java.lang.IllegalArgumentException: wrong number of arguments[/java]

I solved the issue by simply renaming my own method to:

[java]<interact onPrimaryRelease=“onReleased()” onPrimaryClick=“onPress()” />[/java]

It would have been alot easier if Nifty just threw the Exceptions, instead of logging them, no stack trace is quite a headace, it seems to trade Debuggability for stability…

Hi, I’m getting same error with all mine textfield controllers, when i’m pressing with mouse on it, and i can’t avoid using them, my app is still working just all this warning is enoying, maybe someone have solved this problem ?

as per documentation, you can just add these lines, though personally I would only add them when i’m ready for release.

[java]
Logger.getLogger(“de.lessvoid.nifty”).setLevel(Level.SEVERE);
Logger.getLogger(“NiftyInputEventHandlingLog”).setLevel(Level.SEVERE);
[/java]

c# had a cool feature where you could add “#if debug / #endif” to your code that would only execute if using a debug build. I guess you can just add a static boolean somewhere and use that instead.

1 Like

thanks for this tip, it’s good i you want just to hide this error. If I’m not gonna find better solution i will use this one :wink: