java Swing:在 jMenu 的 menuItem 中创建复选框或复选符号

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12476128/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 09:04:00  来源:igfitidea点击:

Swing: creating a checkbox or check symbol in menuItem of jMenu

javaswingjcheckboxjmenujmenubar

提问by Neeraj singh

I want to create a checkbox or check symbol in front of menuItem in a JMenu. For example, when we open a Notepad file and click on Format menu there is a checkbox in front of Word Wrap menuItem of the Format menu.

我想在JMenu. 例如,当我们打开一个记事本文件并单击“格式”菜单时,“格式”菜单的“自动换行”菜单项前面有一个复选框。

回答by Andrew Thompson

Use a JCheckBoxMenuItemfor check boxes in a menu.

JCheckBoxMenuItem对菜单中的复选框使用 a 。