7/08/2006

NetBeans Now Knows How to Indent Java Annotations

NetBeans 4 is the first java IDE to support JDK 1.5 language features, and it has been working for me very well. One little annoyance in NetBeans 4.1 and 5 is it doesn't know how to indent java annotations. For example, it would indent and format the following method like this:

@Override
public String toString() {
return super.toString();
}
After typing @Override and return, the cursor in the new line is already indented 8 spaces. I have to manually correct it. I have to remember not to press CTRL-SHIFT-F to format code, since it will ruin my carefully and manually formated code and format java annotations in its own unique way.

Finally, it was fixed in NetBeans 5.5 beta and formats it the way I (I guess most people) like:
@Override
public String toString() {
return super.toString();
}
This is also how jEdit and Eclipse 3.2 formats java annotations. Note that @Override doesn't need to be in its own line, but it looks cleaner to me.

3 comments:

Anonymous said...

Actually, if you use @Override(), then netbeans 5 formats correctly ...

Anonymous said...

Actually, Sun Java Studio has 1.5 support already... And supports reverse engineering to uml etc...

Anna said...

Great and Useful Article.

Online Java Training

Java Online Training India

Java Online Course

Java EE course

Java EE training

Best Recommended books for Spring framework

Java Interview Questions








Java Course in Chennai

Java Online Training India