Different IDEs have different shortcuts to reformat code. If you're using:
Netbeans - Ctrl + Shift + F. Eclipse - Ctrl + A to highlight all code, and Ctrl + I to indent it. Or you could just hold down Ctrl + Shift + F
Edit: Check this out if my answer was not sufficient.