Ewe Application Development

18 March 2003

Michael L Brereton

http://www.ewesoft.com/

Starting your Ewe Application

Starting using static void main(). 1

Starting using a Runnable Object 1

Starting using a Form Object 2

Starting using a LiveData Object 2

Starting using a mApp Object 2

 

Starting using static void main()

 

This is, of course, the standard way of starting a Java application, and you can start a Ewe application this way. However you must use ewe.sys.Vm.startEwe() at the start of the method, and you must stop your program running using ewe.sys.Vm.exit(). Here is an example:

 
//##################################################################
public class MainEwe {
//##################################################################
 
public static void main(String args[])
{
        ewe.sys.Vm.startEwe(args); // This line must be executed first.
//
// Now you can do whatever you want.
//
        new ewe.filechooser.FileChooser().execute(); // For example.
//
        ewe.sys.Vm.exit(0); // You must use this to exit the Ewe application.
}
 
//##################################################################
}
//##################################################################

 

To run such a class under a Ewe VM simply do: ewe MainEwe.

 

The other methods of starting a Ewe application are generally only used in special circumstances and if you would like to get started quickly using Ewe, then you can move to the next chapter now.

 

Starting using a Runnable Object

 

In this case, any object that implements java.lang.Runnable can be used. The object will be created and the run() method will be called. When the run() method returns, the application will exit. The class must have a public default constructor that takes no arguments.

 
//##################################################################
public class RunEwe implements Runnable{
//##################################################################
 
public void run()
{
// You can do whatever you wish here.
        new ewe.filechooser.FileChooser().execute(); // For example.
//
// You can access the program arguments via the variable 
// ewe.ui.mApp.programArguments
// When run() returns the application will exit.
// You can always also call ewe.sys.Vm.exit(0); to exit as well.
}
 
//##################################################################
}
//##################################################################

 

Again to run this under ewe simply do: ewe RunEwe

Starting using a Form Object

 

A ewe.ui.Form object is one which is able to display itself on screen using a show() or execute() method. When you tell the Ewe VM to start executing a Form object, it will attempt to create an instance of the Form and then call show() on it. It also sets the exitSystemOnClose variable of the Form to be true. Therefore, by default, when the Form is closed it will exit the application (you can always change this during the running of the application).

 

In order for this to work the Form object must have a public default constructor so that a new instance can be created by the VM. The ewe.filechooser.FileChooser is a type of Form and so you can execute it directly using: ewe ewe.filechooser.FileChooser and jwe ewe.ui.FileChooser.

Starting using a LiveData Object

 

A ewe.data.LiveData Object is one which can provide an ewe.ui.Editor object (a type of Form) to display and edit itself. When you tell the Ewe VM to start executing a LiveData object, it will create an instance of the object and then call getEditor(0) on the object to retrieve the default editor for the object. It will then display the returned Editor object in the same way the Form object is displayed above.

Starting using a mApp Object

 

Every Ewe application must have an instance of ewe.ui.mApp. This acts as the “Main Window” for the application – even though at times it may be invisible. In each of the start methods described previously, a default mApp would have been created and made invisible before your code would actually be run.

 

However it is possible for you to override mApp to have your own customized main window (in fact, in early versions of Ewe, this was the only way to start a Ewe application). However, unless you have a specific reason for overriding mApp, you should use one of the other methods described above.