JMECanvas Example not working and some questions

Hello^^



First of all I want to inform you that this example: http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/awt/TestCanvas.java does throws a NPE

Schwerwiegend: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.NullPointerException
at com.jme3.app.SimpleApplication.loadStatsView(SimpleApplication.java:190)
at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:203)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:118)
at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:189)
at java.lang.Thread.run(Unknown Source)


I'm currently to tired to hunt it, maybe someone has a quick guess why that happens.

Now my question (the reason why I wanted to try the example):
I have a JME Canvas to replace buggy nifty in my editor. It works really well as long as I do not need JTextFields (JButtons and CheckBoxes are working fine). I can click into it and write until the application fully starts. Then the app constantly grabs the focus and thats a little annoying...
I tried out to set the canvas to focusable(false) but that does just work until I click into the scene once. Then no KeyInput comes to my TextField.

And a second question: Is there really no other way than using a canvas to be able to use the maximize function? (Like in Minecraft or in all other Windows Programs with the button next to the x-button^^)

This is the same problem I’m talking about here: http://hub.jmonkeyengine.org/groups/general-2/forum/topic/swing-canvas-and-events/



Good luck getting an answer! The only way I’ve made it working is switching to a different program and then back again - at which point controls can get focus until the canvas gets focus. At which point you have to switch again.



(Fortunately I’m only using the canvas in a test harness so I’m able to work around it, it wouldn’t be acceptable in anything an end user sees though!)

Oh, I missed that post (because one day ago I did not plan to use Canvas^^).


it wouldn’t be acceptable in anything an end user sees though!


That's true for my 2 workarounds, too:
Using buttons to type in the numbers (like on a calculator) and a JOptionPane for Textinput (or both). But definitely not a nice solution^^

I’m having a NPE too… and a class not found exception.

I’m a newbie on JME and SWING.



Here is my log :



java.lang.ClassNotFoundException: jme3test.post.TestRenderToTexture

at java.net.URLClassLoader$1.run(URLClassLoader.java:202)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:190)

at java.lang.ClassLoader.loadClass(ClassLoader.java:307)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)

at java.lang.ClassLoader.loadClass(ClassLoader.java:248)

at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Class.java:169)

at com.mycompany.swingwithjme.TestCanvas.createCanvas(TestCanvas.java:205)

at com.mycompany.swingwithjme.TestCanvas.main(TestCanvas.java:248)

Exception in thread “main” java.lang.NullPointerException

at com.mycompany.swingwithjme.TestCanvas.createCanvas(TestCanvas.java:215)

at com.mycompany.swingwithjme.TestCanvas.main(TestCanvas.java:248)


BUILD ERROR


I don't really understand. Could any of you point me in the right direction ? That would be very helpful... thanks in advance !

It looks like you are missing a library, however if you check that and make sure you aren’t then make sure you follow the steps in the instructions exactly and the swing canvas does work - it just has the input focus problem described above.



Most likely you are doing something in the wrong order.

Ok… It does not seem to be a missing library otherwise I would have some red warnings, which I had earlier but fixed. I’ll look a bit deeper in each step. Thanks !

That class only exists in the tests project.

@normen said:
That class only exists in the tests project.


So should we create it ? And what does this class do ? I realised it is imported with a string, therefore no warning.
@lewisgreen said:
So should we create it ? And what does this class do ? I realised it is imported with a string, therefore no warning.


found it here, could be useful : http://code.google.com/p/jmonkeyengine/source/browse/branches/jme3/src/test/jme3test/post/TestRenderToTexture.java?r=6417

thanks for your help ! I solved my problem otherwise.