streamlined app and applet jmol console + event handling via component listener
[jalview.git] / src / jalview / appletgui / AppletJmol.java
index e45bd28..bf38d32 100644 (file)
@@ -184,17 +184,22 @@ public class AppletJmol extends EmbmenuFrame implements
     coloursMenu.add(user);
 
     helpMenu.add(jmolHelp);
+    this.setLayout(new BorderLayout());
 
     setMenuBar(menuBar);
 
     renderPanel = new RenderPanel();
     embedMenuIfNeeded(renderPanel);
     this.add(renderPanel, BorderLayout.CENTER);
+    scriptWindow = new Panel();
+    scriptWindow.setVisible(false);
+    // this.add(scriptWindow, BorderLayout.SOUTH);
+    
     try
     {
       jmb.allocateViewer(renderPanel, true, ap.av.applet.getName()+"_jmol_",
               ap.av.applet.getDocumentBase(), ap.av.applet.getCodeBase(),
-              "-applet");
+              "-applet", scriptWindow, null);
     } catch (Exception e)
     {
       System.err
@@ -520,23 +525,27 @@ public class AppletJmol extends EmbmenuFrame implements
     {
     }
   }
-
+  Panel splitPane=null;
   public void showConsole(boolean showConsole)
   {
-    if (scriptWindow == null)
+    if (showConsole)
     {
-      scriptWindow = new Panel(new BorderLayout());
-      inputLine = new TextField();
-      history = new TextArea(5, 40);
-      scriptWindow.add(history, BorderLayout.CENTER);
-      scriptWindow.add(inputLine, BorderLayout.SOUTH);
-      add(scriptWindow, BorderLayout.SOUTH);
+      remove(renderPanel);
+      splitPane = new Panel();
+      
+      splitPane.setLayout(new java.awt.GridLayout(2,1));
+      splitPane.add(renderPanel);
+      splitPane.add(scriptWindow);
+      scriptWindow.setVisible(true);
+      this.add(splitPane, BorderLayout.CENTER);
+      splitPane.setVisible(true);
+      splitPane.validate();
+    } else {
       scriptWindow.setVisible(false);
-      history.setEditable(false);
-      inputLine.addKeyListener(this);
+      remove(splitPane);
+      add(renderPanel, BorderLayout.CENTER);
+      splitPane=null;
     }
-
-    scriptWindow.setVisible(!scriptWindow.isVisible());
     validate();
   }