|
/******************************************************************************
Copyright (C) 2005 MakeLogic
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 2 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, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Date : 14th December 2005
Authors : MakeLogic
Design : Ujjwal
Developer : Dharma
********************************************************************************/
package com.makeLogic.utils;
import java.awt.Component;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyVetoException;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.KeyStroke;
import com.makeLogic.Tail;
import com.makeLogic.utils.MLInternalFrame;
/**
* Exit MenuItem is One of the MenuItems of FileMenu.<br>
* It closes all the windows if any<br>
* Closes the Application whenever it is clicked
*/
public class ExitMenuItem extends JMenuItem implements ActionListener
{
//..Declarations
Container container;
ExitMenuItem(Container container)
{
//..calls the superclass constructor for ExitMenuItem
super("Exit");
//..sets the DefaultAccelerator as CTRL+X for the ExitMenuItem
//setAccelerator(KeyStroke.getKeyStroke('X',java.awt.Event.CTRL_MASK,false));
//.. adds the Listener class to the ExitMenuItem
addActionListener(this);
this.container=container;
}
public void setKeyStrokeForExitMenuItem(KeyStroke exitMenuItemKeyStroke)
{
//..sets user defined acceslerator to the ExitMenuItem
setAccelerator(exitMenuItemKeyStroke);
}
public void actionPerformed(ActionEvent evt)
{
/*
* First checks for the Opend Files. If it finds any Opend Files closes it.
* */
/*
//..Intialize the MLInternalFrame to null
MLInternalFrame tempFrame=null;
//..gets the components array of OpendFiles
Component[] components=container.getComponents();
int k=0;
//..searches for the OpendFrames
while(components.length>0&&k<components.length)
{
//..if the File is Opend
if(components[k]instanceof MLInternalFrame)
{
//..gets the OpendFrame
tempFrame=(MLInternalFrame)components[k];
k++;
try
{
//..fires the closing Event
tempFrame.setClosed(true);
}
catch(java.beans.PropertyVetoException pve)
{
JOptionPane.showMessageDialog(null,pve.getMessage(),"MakeLogic:FileMenu",JOptionPane.ERROR_MESSAGE);
}
}
}
*/
//..updates the conf File for Recenly Opened Documents
FileMenu.updateConfFile();
//..Exits from the program
System.exit(0);
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Founder of MakeLogic - A Mobile Solutions and XML Web Services Company. B-Tech engineer from India's reputed IITs.
Designed and Authored products like MicroGraphs, MakeLogic VersionManager and MakeLogic Device Broker. Pls see http://www.makelogic.com
MakeLogic is a strategic business partner of Microsoft, Sun, IBM, HP and Citrix.
Contact : madanuuk@makelogic.com OR +91 - 40 - 55322433