AWT for MI | Structure of MDK Examples
AWT application development for MI is fairly straight-forward - any standard AWT application can easily be MI-enabled.
![]() |
Development of AWT application for MI requires the installation of MI for AWT. See FAQ to find out, how MI for JSP and MI for AWT can be installed on the same PC or Notebook. |
The main class of the AWT application must implement the interface com.sap.ip.me.api.runtime.awt.AwtApplication. This interface inherits certain methods from com.sap.ip.me.api.runtime.Application and add two additional methods:
Method |
Description |
initApplication() |
This method is activated when the application is activated in the MI AWT window (Application -> myApplication) for the first time after the MI framework has been started. This method is used to set up the application, like initializing variables. Subsequent activations of the application from the MI AWT window skip this method and call only the activateApplication() method. |
activateApplication() | This method is activated when the application is activated in the MI AWT window (Application -> myApplication) every time, except when the application is already active. This method contains the code that is needed to run the application. |
deactivateApplication() | This method is called when the user selects another application in the MI AWT window (Application -> myOtherApplication). This method can be used to do final steps before the application is terminated. |
destroyApplication() | This method is called when the user logs off from the MI. This method can be used to do final steps before the application is terminated - similar to method deactivateApplication(). |
getApplicationName() | Returns the technical name of the MI application.
The name specified has to match the archive name and the application name specified in the MI WebConsole. |
getRootPanel() | The method getRootPanel returns the area/container which will be the main area of the AWT-Home. It doesn't necessarily have to be a Panel which is passed, it could also be a sub-class of Panel, for example an Applet. |
actionMenuItem(MenuItem item) |
This method is activated when the user selects a menu item in the MI AWT window (for example Action -> Sync). With the getLabel() method of the MenuItem object the selected item can be identified. Example: if (item.getLabel().compareTo("Exit") == 0) { .... } |
We take the TicTacToe game that Sun Microsystems furnishes as a straight-forward AWT example implementation as part of the JDK and convert it to a MI AWT application.
![]() |
Click here,
to see the original TicTacToe coding from Sun Microsystems. |
The difference between the two applications are the following:
import com.sap.ip.me.api.runtime.awt.AWTConfigurationUI;
import com.sap.ip.me.api.runtime.awt.AwtApplication;
Other useful static methods includes the class AWTConfigurationUI in the same package:
Method |
Description |
public static void setMenu(Menu menu) | Insert in the Mobile Infrastructure framework menu bar the application menu . |
public static void setMenuVisible(boolean visible) | Show and hide the menu bar. |
public static void goHome() | Shows the welcome/home screen of the Mobile Infrastructure. |
The MDK examples use a structure that meets the requirements of the MI style guide and has a structure that can easily adopted to user requirements. See section Structure of MDK Examples for further details.