KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > gjt > jclasslib > browser > BrowserApplication


1 /*
2     This library is free software; you can redistribute it and/or
3     modify it under the terms of the GNU General Public
4     License as published by the Free Software Foundation; either
5     version 2 of the license, or (at your option) any later version.
6 */

7
8 package org.gjt.jclasslib.browser;
9
10 import javax.swing.*;
11 import java.beans.PropertyVetoException JavaDoc;
12 import java.io.File JavaDoc;
13
14 /**
15  * Entry class for the bytecode viewer.
16  *
17  * @author <a HREF="mailto:jclasslib@ej-technologies.com">Ingo Kegel</a>
18  * @version $Revision: 1.2 $ $Date: 2005/01/14 15:01:03 $
19  */

20 public class BrowserApplication {
21
22     /**
23      * Title of the application.
24      */

25     public static final String JavaDoc APPLICATION_TITLE = "Bytecode viewer";
26     /**
27      * System property used to choose default look and feel.
28      */

29     public static final String JavaDoc SYSTEM_PROPERTY_LAF_DEFAULT = "jclasslib.laf.default";
30     /**
31      * Version of the application.
32      */

33     public static final String JavaDoc APPLICATION_VERSION = "3.0";
34     /**
35      * Suffix for workspace files.
36      */

37     public static final String JavaDoc WORKSPACE_FILE_SUFFIX = "jcw";
38
39     private static BrowserMDIFrame frame;
40
41     /**
42      * Entry point for the class file browser application.
43      *
44      * @param args arguments for the application. As an argument, a workspace
45      * file or a class file can be passed.
46      */

47     public static void main(final String JavaDoc[] args) {
48
49         if (!Boolean.getBoolean(BrowserApplication.SYSTEM_PROPERTY_LAF_DEFAULT)) {
50             String JavaDoc lookAndFeelClass = UIManager.getSystemLookAndFeelClassName();
51             try {
52                 UIManager.setLookAndFeel(lookAndFeelClass);
53             } catch (Exception JavaDoc ex) {
54             }
55         }
56
57         frame = new BrowserMDIFrame();
58         frame.setVisible(true);
59
60         if (args.length > 0) {
61             SwingUtilities.invokeLater(new Runnable JavaDoc() {
62                 public void run() {
63                     String JavaDoc fileName = args[0];
64                     File JavaDoc file = new File JavaDoc(fileName);
65                     if (file.exists()) {
66                         if (fileName.toLowerCase().endsWith("." + WORKSPACE_FILE_SUFFIX)) {
67                             frame.openWorkspace(file);
68                         } else if (fileName.toLowerCase().endsWith(".class")) {
69                             BrowserInternalFrame internalFrame = frame.openClassFromFile(file);
70                             try {
71                                 internalFrame.setMaximum(true);
72                             } catch (PropertyVetoException JavaDoc e) {
73                             }
74                         }
75                     }
76                 }
77             });
78         }
79     }
80
81
82 }
83
Popular Tags