KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > jawe > actions > Exit


1 /*
2  * Authors:
3  * Stefanovic Nenad chupo@iis.ns.ac.yu
4  * Bojanic Sasa sasaboy@neobee.net
5  * Puskas Vladimir vpuskas@eunet.yu
6  * Pilipovic Goran zboniek@uns.ac.yu
7  *
8  */

9
10 package org.enhydra.jawe.actions;
11
12 import org.enhydra.jawe.*;
13
14 import javax.swing.JMenuItem JavaDoc;
15 import java.awt.event.ActionEvent JavaDoc;
16 import java.io.*;
17
18 /**
19  * Class that realizes <B>exit</B> action.
20  * Really lame implementation of an exit command.
21  */

22 public class Exit extends ActionBase {
23
24    public Exit (PackageEditor editor) {
25       super(editor);
26    }
27
28    public void actionPerformed(ActionEvent JavaDoc e) {
29       if (JaWE.getInstance().close()) {
30          try {
31             String JavaDoc fileList="";
32             for (int i = JaWE.getInstance().getRecentFilesMenu().getItemCount(); i > 0;) {
33                JMenuItem JavaDoc mItem=((JMenuItem JavaDoc)JaWE.getInstance().
34                   getRecentFilesMenu().getMenuComponent(--i));
35                fileList+=mItem.getText().substring(2);
36                if (i>0) fileList+="\n";
37             }
38             FileOutputStream fos = new FileOutputStream(
39                JaWEConstants.JAWE_USER_HOME + JaWEConstants.RFL_FILENAME);
40             fos.write(fileList.getBytes(JaWEConfig.getInstance().getEncoding()));
41             // Write to file
42
fos.flush();
43             fos.close();
44          } catch (Exception JavaDoc ex) {}
45          System.exit(0);
46       }
47    }
48 }
49
Popular Tags