summaryrefslogtreecommitdiffstats
path: root/languages/java/app_templates/superwaba/sw.java
blob: e1c9927cc544b95577d60d27fc1098305fc65797 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97

/** An example that shows the new user interface gadgets for grayscale */

import waba.fx.*;
import waba.sys.*;
import waba.ui.*;

public class %{APPNAME} extends MainWindow
{
	MenuBar mbar;
	Button pushB;

public %{APPNAME}()
{
	super( "%{APPNAME}", TAB_ONLY_BORDER );

	setDoubleBuffer( true );
	// use native style?
	if ( waba.sys.Settings.platform.equals( "PalmOS" ) )
	{
		waba.sys.Settings.setPalmOSStyle( true );
	}
	// if we are a color device then we can use a nice color
	// otherwise WHITE is the most readable
	if ( !waba.sys.Settings.isColor )
	{
		Color.defaultBackColor = Color.WHITE;
		waba.ui.MainWindow.getMainWindow().setBackColor( Color.WHITE );
	}
	else
	{
		Color.defaultBackColor = new Color( 213, 210, 205 );
		waba.ui.MainWindow.getMainWindow().setBackColor( new Color( 213, 210, 205 ) );
	}
}

public void onStart()
{

	initGUI();
	Settings.appSecretKey = "installed";
}

// Called by the system to pass events to the application.
public void onEvent( Event event )
{
	if ( event.type == ControlEvent.WINDOW_CLOSED )
	{
		if ( event.target == mbar )
		{
			switch ( mbar.getSelectedMenuItem() )
			{
					case 1:
					quitApp();
					break;
					case 101:
					showAbout();
					break;
					default :
					break;
			}
		}
	}
	else if ( event.type == ControlEvent.PRESSED )
	{
		if ( event.target == pushB )
		{
			showAbout();
		}
	}
}

private void showAbout( )
{
	MessageBox mb = new MessageBox( "%{APPNAME}", "This is a small test app." );
	mb.setDoubleBuffer( true );
	popupBlockingModal( mb );
}

private void quitApp()
{
	exit( 0 );
}


private void initGUI()
{
  String col0[] = { "File","Exit..."};
  String col1[] = { "Help","About" };

  pushB = new Button( "Push me" );
  add(pushB, CENTER, CENTER);
  setMenuBar( mbar = new MenuBar( new String[][]{ col0, col1 }) );

}

}