home *** CD-ROM | disk | FTP | other *** search
/ Freelog Special Freeware 25 / FreelogHS25.iso / Dessin / ArtOfIllusion2.2.1 / ArtOfIllusion.jar / bsh / commands / editor.bsh < prev    next >
Text File  |  2005-05-23  |  1KB  |  50 lines

  1. /**
  2.     Open a GUI editor from the command line or in the GUI desktop mode.
  3.     When run from the command line the editor is a simple standalone
  4.     frame.  When run inside the GUI desktop it is a workspace editor.
  5.     See workspaceEditor()
  6. */
  7.  
  8. bsh.help.editor = "usage: editor()";
  9. import java.awt.*;
  10.  
  11. editor() 
  12. {
  13.     if ( bsh.system.desktop != void ) {
  14.         return workspaceEditor( this.interpreter );
  15.     }
  16.  
  17.     this.ta = new TextArea(15,40);
  18.     this.frame = new Frame("Editor");
  19.     frame.add(ta, "Center");
  20.  
  21.     this.p = new Panel();
  22.     this.b = new Button("Eval");
  23.     b.addActionListener(this);
  24.     p.add(b);
  25.     b = new Button("Clear");
  26.     b.addActionListener(this);
  27.     p.add(b);
  28.     b = new Button("Close");
  29.     b.addActionListener(this);
  30.     p.add(b);
  31.  
  32.     frame.add(p, "South");
  33.     frame.pack();
  34.     frame.show();
  35.  
  36.     actionPerformed(e) 
  37.     {
  38.         if ( e.getActionCommand().equals("Close") )
  39.             frame.dispose();
  40.         else if ( e.getActionCommand().equals("Clear") )
  41.             ta.setText("");
  42.         else
  43.             this.interpreter.eval( ta.getText() );
  44.     }
  45.  
  46.     print("Editor started...");
  47.     return frame;
  48. }
  49.  
  50.