[SOLVED] Trouble With findElementByName in MonkeyZone code

This is not good Java, but I did create a workaround.

First, findElementByName(String name) is indeed deprecated, and the correct method is now findElementbyId(String name).

So, I changed all the methods, but was still receiving the dereferencing problems. This, I believe, became strongly enforced in Java 1.7. (The not good coding practices part): So, I enclosed all of my findElement… method calls in try/catch blocks. Viewing the ClientUI.xml file associated with MonkeyZone allowed me to confirm that definitely none of the 12 instances of this call would return null. For any of those calls that needed access to that data afterwards, I initialized the variable to null prior to the try/catch block. Since I knew it wouldn’t be null after getting through the block, I wasn’t worried about messing anything up down the line.

I did wind up with two final errors after finishing this.

There was a problem with a bullet library needing to be upgrading. That problem was resolved from this thread:

Additionally, there was a problem with updating the list of connected client names. You can no longer call getElements() on a single Element in order to create a LinkedList to iterate over. So, I commented out the updating of player names in the lobby. I’ll have to figure out some other way to dynamically update that information.


Ultimately, it works now, so – I’m going to mark this as Solved, even though there are definitely better coding solutions. At least now, my efforts in understanding a simple JME game as a whole can proceed.

Thanks to anyone who even took the time to give this thread a read. If you’ve still got a better solution, I’m still interested in hearing it!