Package com.fiveht.tick.ui.menu

Source Code of com.fiveht.tick.ui.menu.ExitMenuItem

/*
* Copyright (C) 2012 FiveHT Media Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
*/
package com.fiveht.tick.ui.menu;

import com.fiveht.tick.ui.Icons;
import com.fiveht.tick.ui.View;
import com.fiveht.tick.ui.event.ExitEvent;
import com.fiveht.tick.ui.icon.Category;
import com.fiveht.tick.ui.icon.Size;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import javax.swing.JMenuItem;
import javax.swing.KeyStroke;

/**
*
* @author Nathan Crause
*/
public class ExitMenuItem extends JMenuItem implements ActionListener {
   
    private View view;

    public ExitMenuItem(View view) {
        super("Exit", Icons.get(Size._16x16, Category.ACTIONS, "process-stop.png"));
       
        this.view = view;
       
        init();
    }
   
    private void init() {
        setToolTipText("Exit the application");
        setMnemonic(KeyEvent.VK_X);
        setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, KeyEvent.ALT_DOWN_MASK));
        addActionListener(this);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        view.fireExit(new ExitEvent(this));
    }
   
}
TOP

Related Classes of com.fiveht.tick.ui.menu.ExitMenuItem

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.