更改 netbeans GUI 控件的默认外观
嘿,我是 netbeans 新手,我注意到很多应用程序(来自教科书)的控件(按钮等)都有默认样式/外观,如下所示。
(来源:iforce.co.nz)
。
我创建 GUI 时的外观只是标准的 Windows XP 或 7 按钮样式。有没有办法将其更改为上图所示的样式?
这是我当前得到的外观:
(来源:iforce.co.nz)
。
提前致谢。
Hey I'm new to netbeans and I noticed a lot of applications (from textbooks) have a default style/appearance to their controls (buttons etc) as shown below.
(source: iforce.co.nz)
.
the appearance when I'm creating a GUI is just the standard windows xp or 7 button style. Is there a way to change this to the style shown in the image above?
Here is the appearance I am currently getting:
(source: iforce.co.nz)
.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
是的,您可以使用以下代码为 Swing 提供类似 外观和感觉 的 Windows :
Yes, you can give Swing a Windows like look and feel with the following code:
NetBeans 将根据您的 JDK 和操作系统自动选择外观。 NB 在创建 JFrame 时生成了一些代码来设置 L&F,这使得所有内容看起来都像 Windows 组件。如果您想更改 L&F,请查看 JFrame 的源代码,并查找一段折叠的代码,其中写着“外观和感觉设置代码”之类的内容。如果您展开它,您可以根据需要更改它,甚至删除它,这将导致它仅使用默认的 L&F(“金属”),即您图片中的 L&F(“金属”)。请记住,您确实不应该仅仅删除生成的代码,但我只是想在这里指出一点。如果您对
swing
不太熟悉,我建议您手动编写一些应用程序,并且默认情况下它们应该只使用“Metal”L&F。这将使您能够轻松地使用swing。
请参阅此处了解更多信息信息。NetBeans will automatically choose a Look and Feel depending on your JDK and operating system. NB generated some code to set the L&F when you created the JFrame which made everything look like Windows components. If you want to change the L&F, look at the source for your JFrame and look for a collapsed bit of code that says something like "Look and feel setting code." If you expand it you can change it as you like, or even delete it, which will cause it to simply use the default L&F ("Metal"), which is the one in your picture. Bear in mind that you really shouldn't really just delete generated code, but I'm just trying to make a point here. If you're new to
swing
in general, I'd recommend writing some applications by hand, and they should just use the "Metal" L&F by default. This will allow you to get comfortable with working withswing.
See here for more information.请参阅嵌套布局示例,了解提供包含可用 PLAF 的组合的代码,并允许用户在运行时更改 PLAF。
See the nested layout example for code that offers a combo containing the available PLAFs, and allows the user to change the PLAF at run-time.
您可以添加外观。有一些免费的漂亮的可以免费下载。如果您只想要 Windows 的外观和感觉,您可以添加
希望这能回答您的问题。
You can add Look and Feels. There are some free great looking ones which can be downloaded freely. If you only want Windows look and feel you can just add
Hope this answers your question.