05-830, User Interface Software, Spring, 2001
Lecture 9,   February 28, 2001
Copyright © 2001 - Brad Myers


        Previous Lecture     . . .      Next Lecture

Toolkits: Intrinsics, Callbacks, Resources,
Widget Hierarchies, Geometry Management

(About 30-40 minutes)


Widgets as objects

Intrinsics

Resources

Callbacks

Widget Hierarchies

Geometry Management

Standard Motif Application

  1. Include Motif and widget header files
  2. Initialize the toolkit: XtAppInitialize
  3. Create the widgets and put them in composites ("parent")
  4. Register call-backs with the widges
  5. "Realize" the top level widget
  6. Start the main loop: XtAppMainLoop


Simple Hello World Program in Amulet:
#include <amulet.h>
main (void) {
  Am_Initialize ();
  Am_Screen
    .Add_Part (Am_Window.Create ("window")
      .Set (Am_WIDTH, 200)
      .Set (Am_HEIGHT, 50)
      .Add_Part (Am_Text.Create ("string")
        .Set (Am_TEXT, "Hello World!")));
  
  Am_Main_Event_Loop ();
  Am_Cleanup ();
}


Goodbye-world Amulet program with button
#include <amulet.h>

main (void)  {
  Am_Initialize ();
  Am_Screen
    .Add_Part (Am_Window.Create ("window")
	       .Set (Am_WIDTH, 200)
	       .Set (Am_HEIGHT, 50)
	       .Set (Am_FILL_STYLE, Am_Amulet_Purple)
	       .Add_Part (Am_Button.Create ("button")
			  .Set_Part(Am_COMMAND, 
				    Am_Quit_No_Ask_Command.Create()
				    .Set (Am_LABEL, "Goodbye, world!"))));
  Am_Main_Event_Loop ();
  Am_Cleanup ();
}


Goodbye-world Amulet program without button
#include <amulet.h>
Am_Define_Method (Am_Object_Method, void, quit_method, (Am_Object)) {
  cerr << "It was nice knowing you.\n" << flush;
  Am_Exit_Main_Event_Loop();
}

main (void) {
  Am_Object inter;
  Am_Initialize ();
  Am_Screen
    .Add_Part(Am_Window.Create ("window")
	      .Set (Am_WIDTH, 200)
	      .Set (Am_HEIGHT, 50)
	      .Add_Part(Am_Text.Create ("string")
			.Set (Am_TEXT, "Goodbye World!")
			.Add_Part(inter = Am_One_Shot_Interactor.Create())
			)
	      );
  inter.Get_Part(Am_COMMAND)
	Set (Am_DO_METHOD, quit_method);
  Am_Main_Event_Loop ();
  Am_Cleanup ();
}


Minimal Hello-World in Java as Applet using AWT

import java.applet.Applet;
import java.awt.Label;
public class AWTHelloWorld
  extends Applet
{
  public void init ()
  {
    super.init ();
    add ( new Label ( "Hello World!" ) );
  }
}

Hello-World in Java as Applet or Application using Swing (In another file)

Goodbye-World in Java as Applet or Application using AWT (In another file)

Goodbye-World in Java as Applet or Application using Swing (In another file)


Back to 05-830 main page