KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > compiere > apps > AStart


1 /******************************************************************************
2  * The contents of this file are subject to the Compiere License Version 1.1
3  * ("License"); You may not use this file except in compliance with the License
4  * You may obtain a copy of the License at http://www.compiere.org/license.html
5  * Software distributed under the License is distributed on an "AS IS" basis,
6  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
7  * the specific language governing rights and limitations under the License.
8  * The Original Code is Compiere ERP & CRM Business Solution
9  * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
10  * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
11  * created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
12  * Contributor(s): ______________________________________.
13  *****************************************************************************/

14 package org.compiere.apps;
15
16 import java.awt.*;
17 import java.awt.event.*;
18 import java.applet.*;
19 import javax.swing.*;
20
21 /**
22  * Applet Start
23  *
24  * @author Jorg Janke
25  * @version $Id: AStart.java,v 1.2 2001/10/13 00:48:17 jjanke Exp $
26  */

27 public final class AStart extends JApplet
28 {
29     boolean isStandalone = false;
30
31     /**
32      * Get a parameter value
33      */

34     public String JavaDoc getParameter(String JavaDoc key, String JavaDoc def)
35     {
36         return isStandalone ? System.getProperty(key, def) :
37             (getParameter(key) != null ? getParameter(key) : def);
38     }
39
40     /**
41      * Construct the applet
42      */

43     public AStart()
44     {
45     }
46
47     /**
48      * Initialize the applet
49      */

50     public void init()
51     {
52         try
53         {
54             jbInit();
55         }
56         catch(Exception JavaDoc e)
57         {
58             e.printStackTrace();
59         }
60     }
61
62     /**
63      * Component initialization
64      */

65     private void jbInit() throws Exception JavaDoc
66     {
67         this.setSize(new Dimension(400,300));
68     }
69
70     /**
71      * Start the applet
72      */

73     public void start()
74     {
75     }
76
77     /**
78      * Stop the applet
79      */

80     public void stop()
81     {
82     }
83
84     /**
85      * Destroy the applet
86      */

87     public void destroy()
88     {
89     }
90
91     /**
92      * Get Applet information
93      */

94     public String JavaDoc getAppletInfo()
95     {
96         return "Start Applet";
97     }
98
99     /**
100      * Get parameter info
101      */

102     public String JavaDoc[][] getParameterInfo()
103     {
104         return null;
105     }
106
107     /**
108      * Main method
109      */

110     public static void main(String JavaDoc[] args)
111     {
112         AStart applet = new AStart();
113         applet.isStandalone = true;
114         JFrame frame = new JFrame();
115         //EXIT_ON_CLOSE == 3
116
frame.setDefaultCloseOperation(3);
117         frame.setTitle("Start Applet");
118         frame.getContentPane().add(applet, BorderLayout.CENTER);
119         applet.init();
120         applet.start();
121         frame.setSize(400,320);
122         Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
123         frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2);
124         frame.setVisible(true);
125     }
126
127     //static initializer for setting look & feel
128
static
129     {
130         try
131         {
132             UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
133             //UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
134
}
135         catch(Exception JavaDoc e)
136         {
137         }
138     }
139 } // AStert
140
Popular Tags