java swing 添加菜单,Java / Swing:将项添加到系统菜单

这篇博客探讨了如何在Java Swing应用程序中模仿Windows窗口左上角的系统菜单,并通过使用JNI/JNA调用GetSystemMenu函数来添加自定义菜单项。虽然纯Java/Swing没有直接的方法实现,但可以通过Windows API进行扩展。
摘要由CSDN通过智能技术生成

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:

y3Fs2.png

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).

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值