Here you can find the source of createCheckBoxMenuItem(final JInternalFrame f)
public final static JMenuItem createCheckBoxMenuItem(final JInternalFrame f)
//package com.java2s; /*/*ww w . j a v a 2 s . com*/ * Copyright 2007, Plutext Pty Ltd. * * This file is part of Docx4all. Docx4all is free software: you can redistribute it and/or modify it under the terms of version 3 of the GNU General Public License as published by the Free Software Foundation. Docx4all is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Docx4all. If not, see <http://www.gnu.org/licenses/>. */ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.beans.PropertyVetoException; import javax.swing.JCheckBoxMenuItem; import javax.swing.JInternalFrame; import javax.swing.JMenuItem; public class Main { public final static JMenuItem createCheckBoxMenuItem(final JInternalFrame f) { final JMenuItem theItem = new JCheckBoxMenuItem(f.getTitle()); theItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { f.setSelected(true); f.setIcon(false); } catch (PropertyVetoException exc) { ;//do nothing } f.show(); if (!theItem.isSelected()) { theItem.setSelected(true); } } }); return theItem; } }