Convert Java GUI Builder .form files to Source Code?
Asked Answered
L

3

9

I have created a fairly substantial Java GUI application with many form windows where the settings are locked up in .form files. I am wondering is there any way to convert or refactor these .form files into real Java source code that I can modify?

The GUI was created using Netbeans 6.5.

Librarianship answered 23/4, 2009 at 12:16 Comment(1)
I thought that .form files are Netbeans specific and that the .java files have the full source code for the windows. Isn't this correct? Can't you edit the java files?Moreen
G
7

My understanding is that the ".form" files are only used by the Netbeans GUI builder to keep track of where the GUI components are. When you add components in the design view, Netbeans automatically updates the actual source (.java) files. You can actually modify these .java files directly to, say, change the label on a button, but if you do it within Netbeans, it will use the .form files to automatically regenerate the source files, destroying your manual changes.

In my experience, once you make the decision to modify the .java files manually, the .form files become out of sync and you will no longer be able to use the Netbeans GUI builder properly.

Gilligan answered 23/4, 2009 at 19:55 Comment(0)
C
4

kazanaki is right, the java files that are generated can be modified but the resulting .java files are notoriously messy, large and hard to interpret. Also, you cannot change some things (as noted in the comments in the generated .java file) without rendering matisse useless because it expects the file to have things in a certain way. That being said, if you are careful not to step on Matisse's toes you can code away and it will not touch your code which is nice.

Outlaw is right too, if you change anything that is already in Matisse's perview it will be overwritten. Any changes that you make outside of matisse must be outside of any element that is covered by the xml that matisse uses to generate the code.

I have tried this kind of thing before with limited success and eventually just rewrote the interface to avoid these maddening headaches.

Clarettaclarette answered 23/4, 2009 at 20:3 Comment(0)
L
1

I can edit the source, I discovered the solution. THe problem was that I was using the "AbsoluteLayout" in the GUI builder. Netbeans was creating some hidden AbsoluteLayout class that was inside the .form files. IF I deleted the .form files the project would no longer build. The solution was to change the form to be of "FreeForm" layout and then I could delete the .form files and remove the GUI builder comments.

Thank you for the help guys, I give you both +1.

Librarianship answered 24/4, 2009 at 9:0 Comment(1)
You can add external lib for "AbsoluteLayout" from "jar-download.com/…" then it will build properlyFugitive

© 2022 - 2024 — McMap. All rights reserved.