The other day I was putting together a test harness for a project. I decided to try the cool Swing Desktop Application framework that comes with NetBeans 6. An hour later I had a fully working and tested test harness (rapid app development in Java is now possible!). The last part was to build a standalone binary distribution of this and run it the test environment.
At this point I hit a major stumbling block. As my NetBeans runs on JDK 1.6, NetBeans created all the group layout GUI code with the GroupLayout javax.swing packages and classes that come by default with Java 1.6. However, the test environment I was going to be running on, only had Java 1.5, and could not be upgraded easily. The GroupLayout code does not work in Java 1.5. I couldn't find much in google on how to switch between the two, and remembered that a year ago I tried to do a similar conversion with find..replace from javax.swing to org.jdesktop which didn't work due to class interface differences.
After playing around in Matisse for a while, I worked out how to get NetBeans 6 to do this conversion for you. The best part is it does it quickly and effortlessly.
Bring up the GUI class in question, and switch to the Matisse designer view of that class. In the Inspector pane, select the form, right-click on it and click Properties as the following screenshot illustrates:
In the resulting properties dialog, there is an option Layout Generation Style, which facilitates the switching from pre-Java 1.6 and Java 1.6. Simply select Swing Layout Extensions Library and NetBeans immediately converts your code. The next screenshot illustrates the options in the aforementioned properties dialog:
Sweet!
-
-
6
comments
Thank you.. this was useful..
Curiously, there is a global setting for
Layout Generation Style, but it doesn't seem to apply itself to each form class.
I found that if I have a bunch of GUI classes, I have to toggle the Layout Generation Style property individually on each class. Sometimes, I have to switch it to "Standard Java 6 code" then immediately choose "Swing Layout Extensions Library" in order to force it to regenerate the form code.
Thank you, really helped me out with this and saved a lot of trouble!
very useful!
This post tells you about NetbBeans 6.1 which include very important feature of switching between org.jdesktop to javax.swing. The screenshot given in this post help me a lot in understanding the conversion. Thanks for the post.
Ecorptrainings.com provides JAVA SWING in hyderabad with best faculties on real time projects. We give the best online trainingamong the JAVA SWING in Hyderabad. Classroom Training in Hyderabad India