My team just got the NavX MXP as well and I'm going to begin programming it myself.
In terms of what you can do with the NavX MXP, there is a detailed documentation on their site at
http://www.pdocs.kauailabs.com/navx-mxp/
As for the location of that code, it looks like it should work if you put it in the Robot() constructor.
Hope this helps!