在 javafx 2.0 中设计 GUI 的最佳方法是什么?

发布于 2024-12-22 19:08:27 字数 113 浏览 4 评论 0原文

在 javafx 2.0 中,可以使用 FXML 方法或使用普通的 java 代码来创建布局。 对于一组精心设计的 UI 来说,最好的方法是什么?在我的应用程序中有大约 100 个子 UI。

谢谢

In javafx 2.0 it is possible to create the layout by using FXML approach or by using normal java code.
What is the best way with respect to a well designed set of UIs. In my application there is about 100 sub UIs.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

李白 2024-12-29 19:08:28

FXForm2 是一个提供自动 JavaFX 2.0 表单生成的库。

但是 FXForm2 并不是完整的所见即所得 GUI 设计工具。

http://dooapp.github.io/FXForm2/

FXForm2 is a library providing automatic JavaFX 2.0 form generation.

however FXForm2 is not full WYSIWYG GUI design tool.

http://dooapp.github.io/FXForm2/

谎言 2024-12-29 19:08:28

场景构建器应该是创建应用程序的独特 UI 的良好起点。考虑到您有数百个 UI,我认为它们的某些“外观”应该相同,但功能略有不同。您可以动态加载 FXML 并在运行时分配控制器。这意味着 1 个 FXML 文件可以与多个控制器一起使用。这可以节省您一些时间,同时保持代码动态以便于维护。

    FXMLLoader loader = new FXMLLoader(getClass().getResource("DBedit.fxml"));
    loader.setController(new DBeditEntityUser());

因此,要在不同的控制器上使用相同的 FXML。

    FXMLLoader loader = new FXMLLoader(getClass().getResource("DBedit.fxml"));
    loader.setController(new DBeditEntityUserLevel());

希望这有帮助。

Scene builder should be a good starting point to create unique UIs of your application. Considering you have 100s of UIs, I assume that some of their "appearances" should be identical with slightly different functions. You can load the FXML dynamically and assign controller at run time. Which means 1 FXML file can be used with multiple controllers. Which can save you some time while keeping the code dynamic for easier maintenance.

    FXMLLoader loader = new FXMLLoader(getClass().getResource("DBedit.fxml"));
    loader.setController(new DBeditEntityUser());

So, to make use of the same FXML with a different controller.

    FXMLLoader loader = new FXMLLoader(getClass().getResource("DBedit.fxml"));
    loader.setController(new DBeditEntityUserLevel());

Hope this helps.

维持三分热 2024-12-29 19:08:28

仅供参考,

Java fx http://javafx.com/roadmap/ 的路线图显示场景构建器将是于年中左右发布。从上面的网页:

“JavaFX Scene Builder 是一个所见即所得的 GUI 设计工具,用于
JavaFX 平台。它可以通过简单地设计用户界面屏幕
将 GUI 组件从调色板拖放到场景上。

该工具生成可在项目中使用的 FXML 格式2文件
在任何 IDE(例如 NetBeans 或 Eclipse)中。 JavaFX 场景生成器可以是
用于为在浏览器中运行的桌面应用程序和小程序创建 GUI。”

fyi,

road map for Java fx http://javafx.com/roadmap/ shows that the scene builder will be released around middle of the year. From the above web page:

"JavaFX Scene Builder is a WYSIWYG GUI design tool for the
JavaFX platform. It enables designing user interface screens by simply
dragging and positioning GUI components from a palette onto a scene.

The tool generates files in FXML format2 that can be used within a project
in any IDE such as NetBeans or Eclipse. The JavaFX Scene Builder can be
used to create GUI for desktop applications and applets that run in a browser."

百思不得你姐 2024-12-29 19:08:27

对于此目的,FXML 看起来更合乎逻辑。通过使用 FXML,

  • 您可以从视图中分离业务逻辑,
  • 您可以选择编辑设计而无需重新编译项目。
  • 您将获得结构化 xml 树的设计,与使用 SceneBuider 工具潜在随机排序的 java 代码相比,它更容易编辑
  • 您可以选择对 fxml 文件使用可视化编辑器

FXML looks more logical for that purpose. By using FXML

  • you split business logic from view
  • you get option to edit design without recompiling project.
  • you get design as structured xml tree which is much easier to edit comparing to potentially randomly ordered java code
  • with SceneBuider tool you get an option to use visual editor for your fxml files
伪心 2024-12-29 19:08:27

在此处获取 JavaFX Scenebuilder

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文