Mario,
 
You need to start an interpreter thread. Just add the following line:
new Thread(interpreter).start();
 
to obtain in your code:
 
 protected void createConsoleFrame() {
   JConsole console = new JConsole();
   Interpreter interpreter = new Interpreter(console);
   JFrame frame = new JFrame("My console frame");
   frame.getContentPane().add(console);
 
   new Thread(interpreter).start(); // <--- Start the interpreter thread

   frame.pack();
   frame.setVisible(true);
 }
You can also look at the source of JDemoApplet.java in src/bsh/util.
 
Regards,
 
Andre
 
 
----- Original Message -----
From: Mario Juric
To: beanshell-users@lists.sourceforge.net
Sent: Monday, December 17, 2001 9:37 AM
Subject: [Beanshell-users] Using JConsole

We would like to embed the BeanShell interpreter into our own application with a custom console user interface and the application data model included in the interpreters namespace. We therefore need to implement our own console that can interact with the Interpreter. I do some basic experiments in order to understand how things work. First, I made a few changes to the "desktop" and "makeWorkspace" scripts, so that my application data model was included in the interpreter namespace of BeanShell's standard GUI workspace.
 
In the next step I am trying to build my own simple console using JConsole as basis:
 
 protected void createConsoleFrame(Interpreter interpreter) {
   JConsole console = new JConsole();
   interpreter.setConsole(console);
   JFrame frame = new JFrame("My console frame");
   frame.getContentPane().add(console);
   frame.pack();
   frame.setVisible(true);
 }
Note, In the final application I need to be able to pass the interpreter as parameter. However, I can write to the console but there is no reply coming out from the Interpreter. Alternatively I tried the following with the same result:
 
 protected void createConsoleFrame() {
   JConsole console = new JConsole();
   Interpreter interpreter = new Interpreter(console);
   JFrame frame = new JFrame("My console frame");
   frame.getContentPane().add(console);
   frame.pack();
   frame.setVisible(true);
 }
I am studying the source code, but It will take time to figure out what I do wrong. Any suggestions for a quick start?
 
Best Regards,
Mario Juric
 
---
Mario Juric, M.Sc. CS, MUSTER Product Manager
IFAD, Forskerparken 10, DK - 5230 Odense M
Phone: +45 63 15 71 31 Fax: +45 65 93 29 99
www: www.ifad.dk e-mail: mario.juric@ifad.dk
---