Java/Swing:向系统菜单添加项目 [英] Java/Swing: adding items to the system menu

查看:25
本文介绍了Java/Swing:向系统菜单添加项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我忘记了它的确切名称(我认为它是系统菜单"),但在 Windows 中,窗口左上角有一个图标,如果您单击它,则会出现一个弹出菜单:

有没有办法在 Swing 中为此添加自定义菜单项?

解决方案

我不知道用纯 Java/Swing 直接执行此操作的方法.但是,您可以使用 JNI/JNAGetSystemMenu 函数在 User32.dll 中找到以修改它.<块引用>

使应用程序能够访问窗口菜单(也称为系统菜单或控制菜单)进行复制和修改.

实际上,维基百科在系统菜单上有一个很好的条目.

<块引用>

某些应用程序自定义系统菜单,通常通过 GetSystemMenu WinAPI 函数.1 Cmd.exe 是一个示例,并为用户提供通过其系统菜单更改其首选项的能力(其他应用程序通常允许用户通过其窗口标题栏下方的普通菜单更改其首选项).

I forget what this is called exactly (I think it's the "system menu"), but in Windows there's an icon in the upper left of a window and if you click it, a popup menu becomes visible:

Is there a way to add a custom menu item to this in Swing?

解决方案

I do not know a way to do this directly with pure Java/Swing. However, you can use JNI/JNA and GetSystemMenu function found in User32.dll to modify it.

Enables the application to access the window menu (also known as the system menu or the control menu) for copying and modifying.

Actually, Wikipedia has a good entry on the System Menu.

Some applications customize the system menu, typically through the GetSystemMenu WinAPI function.1 Cmd.exe is an example of this and offers the user an ability to change its preferences through its system menu (other applications typically offer the user to change their preferences through the normal menu below their window's title bar).

这篇关于Java/Swing:向系统菜单添加项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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