How to Fix Netbeans’ GroupLayout Incompatibility with Java 5.0 (and Less)

Netbeans has a very powerful feature for its Swing designer, but too bad the default swing designer generates soucecode using javax.swing.GroupLayout and it’s only available at Java 6. I found this problem early this morning, somehow i design the Swing UI using Netbeans but i have to deploy my application in a Java 5 environment. Btw, im using Netbeans 6.9.

Below is the screenshot for Netbeans’ free design layout.

And this is the generated sourcecode, it works well with java 6.0

But when im using Java 5, it generates lots of errors

So, the workarouds are whether i change all the UI layout designs from GroupLayout to NullLayout, or find a way so GroupLayout is compatible with Java 5.

Because the second workaround is much promising, so i googled a while and found out that it’s actually not to difficult to make GroupLayout is compatible with Java 5. This is how i do it.

Right click, and choose Properties

And choose Swing Layout Extension Library.

Suddenly all the javax.swing.GroupLayout changed into org.jdesktop.layout.GroupLayout. And dont forget to include swing-layout*.jar, because org.jdesktop.layout.GroupLayout located in it.

See, it’s not that hard right? (H)

Google+

4 Comments

Definiendum

about 6 years ago

Another possibility would be to arrive in 2006 and install Java 1.6

Reply

edwin

about 6 years ago

hi Definiendum, sometimes we just couldnt change our production environment, thanks for your comment though.

Pavol paluga

about 6 years ago

Thank you for your advice, it is one of the few very precise advice on web sites

Reply

edwin

about 6 years ago

Thanks pavol, glad it can help :)

Leave a Comment

Please be polite. We appreciate that.
Your email address will not be published and required fields are marked


:-[ (B) (^) (P) (@) (O) (D) :-S ;-( (C) (&) :-$ (E) (~) (K) (I) (L) (8) :-O (T) (G) (F) :-( (H) :-) (*) :-D (N) (Y) :-P (U) (W) ;-)