如何在 Java Swing 中生成“.form"文件? [英] How to generate '.form' file in Java Swing?

查看:115
本文介绍了如何在 Java Swing 中生成“.form"文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 .java 文件.我需要使用 .java 文件生成一个 .form 文件.当我编写一个 .java 文件时,应该自动创建一个 .form 文件.使用java Swing,我们如何创建.form 文件?

I have a .java file. I need to generate a .form file using the .java file. When I write a .java file then automatically a .form file should be created. By using java Swing, how can we create a .form file?

推荐答案

您的问题很模糊,但通常情况相反 - 您从由 GUI 设计器(如 NetBeans)创建的表单文件生成 Java 代码Matisse、Eclipse Jigloo 或 IntelliJ IDEA 表单设计器.尽管它们都使用 .forms 扩展名,但内部格式在不同的 IDE 上大不相同——通常是一些 XML 标记,稍后用于生成与 GUI 布局相关的 Java 代码,因此您不必自己编码.我发现很难相信您想从现有布局生成表单文件.

Your question is as vague as they get, but usually it's the other way around - you generate 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 generate 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.

据我所知,Sun Java Studio Enterprise 是基于 NetBeans 的,所以您的 GUI 设计师可能是 Matisse.没有办法从 Java 代码重新生成表单(至少你编写一些工具来解析 initComponents() 方法中的代码,这将是一个开始,但还不够取回一切).正如@gnoupi 指出的那样,在您发布的另一个问题中,最好的办法是阅读现有源代码并根据它恢复表单.当然,所有这些都假设您没有使用版本控制,并且无法从那里恢复项目丢失的表单文件.

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 the 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 out, 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 no way to restore the project's missing form file from there.

这篇关于如何在 Java Swing 中生成“.form"文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆