Java、Netbeans:GUI 看起来为何不同?

发布于 2024-08-09 19:05:31 字数 362 浏览 4 评论 0原文

我是一名 Java/Netbeans 新手,正在学习如何制作 GUI。

我正在关注这个教程,我注意到“成品”产品(其中的第一张图片)链接)看起来不像通过这些步骤构建的 GUI。

这是为什么?我的意思是,当我单击预览按钮时,GUI 看起来也很原生(很好)。只是当它部署时,它看起来很……嗯……很糟糕。哈哈。

有没有办法让最终的 GUI 看起来像原生的?是 Netbeans 设置还是 Java 设置?

注意:我正在 Windows 上开发这个。

I'm a Java/Netbeans newbie learning how to make a GUI.

I was following this tutorial, and I noticed that the "finished" product (first picture in that link) doesn't look like the GUI built through the steps.

Why is that? I mean, when I click on the preview button, the GUI looks native (nice) as well. It's just when it's deployed that it looks all...mmm...bad. lol.

Is there a way to make the finished GUI looks native? Is it Netbeans settings or Java settings?

Note: I'm developing this on Windows.

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

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

发布评论

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

评论(3

花开半夏魅人心 2024-08-16 19:05:31

使用以下代码强制 swing 选择“系统”外观:

String laf = UIManager.getSystemLookAndFeelClassName();
UIManager.setLookAndFeel(laf);

Use the following code to force swing to select the "system" look and feel:

String laf = UIManager.getSystemLookAndFeelClassName();
UIManager.setLookAndFeel(laf);
惯饮孤独 2024-08-16 19:05:31

默认的“外观和感觉”是类似金属的,这对于跨平台应用程序来说非常好。

JDK 有 4 个内置的“外观和感觉”(到目前为止),它们是:

  • com.sun.java.swing.plaf.gtk.GTKLookAndFeel
  • javax.swing.plaf.metal.MetalLookAndFeel
  • com.sun.java.swing。 plaf.windows.WindowsLookAndFeel
  • com.sun.java.swing.plaf.motif.MotifLookAndFeel

您可以在 1 行中尝试任何这些“外观和感觉”,示例代码:

UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");

注意:调用/调用此方法来更改“外观和感觉”在任何 GUI 实现之前感觉”,否则可能会抛出一些异常

The default "Look and Feel" is metal-like, which is good and nice for cross-platform applications.

JDK has 4 built-in "look and feel" ('til now), which are:

  • com.sun.java.swing.plaf.gtk.GTKLookAndFeel
  • javax.swing.plaf.metal.MetalLookAndFeel
  • com.sun.java.swing.plaf.windows.WindowsLookAndFeel
  • com.sun.java.swing.plaf.motif.MotifLookAndFeel

you can try any of these "look and feel"s in 1 line, example code:

UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");

NOTE: invoke/call this method of changing the "look and feel" before any GUI implementation, or it may throw some exception

东走西顾 2024-08-16 19:05:31

这称为“外观”。您可以在启动应用程序时或以编程方式使用各种外观和感觉。有关详细信息,请参阅此 Sun 教程

This is referred to as the "look and feel". You can use various look and feel either when launching your app or programaticaly. See this Sun tutorial for more info.

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