如何在 Java Swings 中生成 .form 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2919291/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to generate .form file in Java swings
提问by charan
i have .java file. i need to generate .form file using the java file. when i write a java file then automatically .form file should be created. by using java swings how can we create .form file
我有 .java 文件。我需要使用 java 文件生成 .form 文件。当我写一个 java 文件时,应该自动创建 .form 文件。通过使用 java swings 我们如何创建 .form 文件
回答by Bozhidar Batsov
Your question is as vagues as they get, but usually it's the other way around - you generated java code from a form file created by a GUI designer such as NetBeans Matisse, Eclipse Jigloo or IntelliJ IDEA Forms designer. Although they all use the .forms extension the internal format differs wildly on different IDEs - it's generally some xml markup, that's later used to generated to Java code related to the GUI layout, so you wouldn't have to code it yourself. I find it hard to believe you want to generate form files from an existing layout...
您的问题很模糊,但通常情况相反 - 您从由 GUI 设计器(例如 NetBeans Matisse、Eclipse Jigloo 或 IntelliJ IDEA 表单设计器)创建的表单文件生成 Java 代码。尽管它们都使用 .forms 扩展名,但内部格式在不同的 IDE 上有很大差异 - 通常是一些 xml 标记,稍后用于生成与 GUI 布局相关的 Java 代码,因此您不必自己编写代码。我发现很难相信您想从现有布局生成表单文件...
As far as I know Sun Java Studio Enterprise is based on NetBeans, so probably your GUI designer is Matisse. There is no way to regenerate the form from they Java code(at least nothing short of you writing some tool to parse the code in the initComponents() method, which will be a start, but not enough to get everything back). As gnoupi pointed in the other question you posted - your best bet would be to read the existing source and restore the form based on it. All this of course assumes that you're not using version control and there is not way to restore the project's missing form file from there.
据我所知,Sun Java Studio Enterprise 是基于 NetBeans 的,所以您的 GUI 设计师可能是 Matisse。没有办法从它们的 Java 代码中重新生成表单(至少你编写了一些工具来解析 initComponents() 方法中的代码,这将是一个开始,但还不足以恢复所有内容)。正如 gnoupi 在您发布的另一个问题中指出的那样-您最好的选择是阅读现有源代码并根据它恢复表单。当然,所有这些都假设您没有使用版本控制,并且无法从那里恢复项目丢失的表单文件。

