All Downloads are FREE. Search and download functionalities are using the official Maven repository.

bsh.util.commands.editor.bsh Maven / Gradle / Ivy

The newest version!
/**
	Open a GUI editor from the command line or in the GUI desktop mode.
	When run from the command line the editor is a simple standalone
	frame.  When run inside the GUI desktop it is a workspace editor.
	See workspaceEditor()
*/

bsh.help.editor = "usage: editor()";
import java.awt.*;

editor() 
{
	if ( bsh.system.desktop != void ) {
		return workspaceEditor( this.interpreter );
	}

	this.ta = new TextArea(15,40);
	this.frame = new Frame("Editor");
	frame.add(ta, "Center");

	this.p = new Panel();
	this.b = new Button("Eval");
	b.addActionListener(this);
	p.add(b);
	b = new Button("Clear");
	b.addActionListener(this);
	p.add(b);
	b = new Button("Close");
	b.addActionListener(this);
	p.add(b);

	frame.add(p, "South");
	frame.pack();
	frame.show();

	actionPerformed(e) 
	{
		if ( e.getActionCommand().equals("Close") )
			frame.dispose();
		else if ( e.getActionCommand().equals("Clear") )
			ta.setText("");
		else
			this.interpreter.eval( ta.getText() );
	}

	print("Editor started...");
	return frame;
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy