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
Swing: creating a checkbox or check symbol in menuItem of jMenu
提问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 JCheckBoxMenuItem
for check boxes in a menu.
JCheckBoxMenuItem
对菜单中的复选框使用 a 。