01: /*****************************************************************************
02: * *
03: * This file is part of the BeanShell Java Scripting distribution. *
04: * Documentation and updates may be found at http://www.beanshell.org/ *
05: * *
06: * BeanShell is distributed under the terms of the LGPL: *
07: * GNU Library Public License http://www.gnu.org/copyleft/lgpl.html *
08: * *
09: * Patrick Niemeyer (pat@pat.net) *
10: * Author of Exploring Java, O'Reilly & Associates *
11: * http://www.pat.net/~pat/ *
12: * *
13: *****************************************************************************/package bsh.util;
14:
15: import javax.swing.*;
16: import java.awt.*;
17: import bsh.*;
18: import bsh.util.*;
19:
20: /**
21: Run bsh as an applet for demo purposes.
22: */
23: public class JDemoApplet extends JApplet {
24: public void init() {
25: String debug = getParameter("debug");
26: if (debug != null && debug.equals("true"))
27: Interpreter.DEBUG = true;
28:
29: String type = getParameter("type");
30: if (type != null && type.equals("desktop"))
31: // start the desktop
32: try {
33: new Interpreter().eval("desktop()");
34: } catch (TargetError te) {
35: te.printStackTrace();
36: System.out.println(te.getTarget());
37: te.getTarget().printStackTrace();
38: } catch (EvalError evalError) {
39: System.out.println(evalError);
40: evalError.printStackTrace();
41: }
42: else {
43: getContentPane().setLayout(new BorderLayout());
44: JConsole console = new JConsole();
45: getContentPane().add("Center", console);
46: Interpreter interpreter = new Interpreter(console);
47: new Thread(interpreter).start();
48: }
49: }
50: }
|