How do I port a Java Desktop Application to Netbea

2019-02-26 12:27发布

问题:

In Netbeans 6, I wrote a fairly complex application based on the java desktop application (org.jdesktop.application. SingleFrameApplication).

The Swing Application Framework has been removed from 7.1 and I now cannot edit the forms. I have been through the the examples of porting to the Netbeans Platform but they don't seem to cover migrating from a desktop application.

Any help would be welcome.

回答1:

Unfortunately the Swing Application Framework was deprecated and removed. It never became a final JSR, and at this point is fully dead (since JavaFX is considered the future of Java UIs).

To make your app run, copy the swing app jars from an older copy of NetBeans (they may have been inserted into your app's lib directory as well). You should still be able to run with this jar.

To make further changes to the actual forms you basically have just two options: completely recreate them with the standard form builder or edit them as code instead of visually. You can throw away the .form files, since they are useless now. Instead you can modify the generated code inside the form's java class. It's still rather ugly code, but at least it will be editable now. You may need to remove the magic comments that NetBeans uses to mark blocks of code as uneditable.