简体   繁体   English

Java Swing退出图标?

[英]Java Swing Exit Icon?

I was wondering how to change the minimize, maximize, and exit button icons in the top left of the default JFrame swing window? 我想知道如何更改默认JFrame摇摆窗口左上角的最小化,最大化和退出按钮图标? I've looked everywhere and can't find a tutorial or method that does it. 我到处寻找,找不到可以做到的教程或方法。

Minimize, maximize/restore and close buttons are bound to the frame decoration used. 最小化,最大化/恢复和关闭按钮绑定到所使用的框架装饰。

If you are using a frame decorated by system (for example some Aero frame in Windows 7) - you cannot modify those buttons since the whole frame decoration is provided by system and there is no good way to invtervene and change its behavior. 如果您使用的是由系统装饰的框架(例如Windows 7中的某些Aero框架) - 您无法修改这些按钮,因为整个框架装饰由系统提供,并且没有好的方法来调用并改变其行为。

On the other hand - if you are using a custom Look and Feel (shorty - L&F) written on Java and it provides its own frame decoration - it is possible to modify it if you have access to that L&F sources or if that L&F provides some options to add/remove those buttons. 另一方面 - 如果您使用在Java上编写的自定义外观(简称 - L&F)并且它提供了自己的框架装饰 - 如果您可以访问L&F源或者L&F提供了一些,则可以修改它添加/删除这些按钮的选项。

You can read more about L&F here: 你可以在这里阅读更多关于L&F的信息:
http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel

You can also find a lot of links to custom L&Fs here: 您还可以在此处找到许多自定义L&F的链接:
Java Look and Feel (L&F) Java外观(L&F)

  1. Start with JFrame.setDefaultLookAndFeelDecorated(true) . JFrame.setDefaultLookAndFeelDecorated(true)开始JFrame.setDefaultLookAndFeelDecorated(true)
  2. Then set the Pluggable Look and Feel . 然后设置Pluggable Look and Feel

For best results, this is most reliably done before the first GUI element is visible on screen. 为了获得最佳结果,在屏幕上显示第一个GUI元素之前,这是最可靠的。

See How to Make Frames - Specifying Window Decorations for more info. 有关详细信息,请参见如何制作框架 - 指定窗口装饰

在此输入图像描述金属装饰

As far as I know, you cannot, but if this is something you need to have done, you can use Netbeans to use JavaFX, which allows you to fully customize the window, including the buttons like that. 据我所知,你不能,但如果这是你需要做的事情,你可以使用Netbeans使用JavaFX,它允许你完全自定义窗口,包括这样的按钮。 The window doesnt even need to have these buttons. 窗口甚至不需要这些按钮。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM