Java JCheckBoxMenuItem createCheckBoxMenuItem(final JInternalFrame f)

Here you can find the source of createCheckBoxMenuItem(final JInternalFrame f)

Description

create Check Box Menu Item

License

Open Source License

Declaration

public final static JMenuItem createCheckBoxMenuItem(final JInternalFrame f) 

Method Source Code

//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;
    }
}

Related

  1. configureJCheckBoxMenuItem( final JCheckBoxMenuItem mi, final Action a)
  2. createCheckBoxMenuItem(final String text, final boolean selected)
  3. createCheckBoxMenuItem(String label, int mnemonic, String description, ItemListener action)
  4. createCheckBoxMenuItem(String text, Icon icon, String toolTip, ActionListener... listeners)
  5. createJCheckBoxMenuItem(String name, String command, ActionListener listener, boolean isSelected)