Previous Tip  |  Next Tip  |  Design Tips   | [Bill's Home]

Java for a Pocket PC

The great thing about Java and Flash is that they can both be run on a Pocket PC. The photograph on the right-hand side shows an example of a Java program, which uses the following Java program:

import java.applet.*;
import java.awt.*;
import java.util.Date;

public class chap10_07 extends Applet
{
String Msg;
Button dbutton1 = new Button("Date 1");
Button dbutton2 = new Button("Date 2");
Button quit = new Button("Quit");
Date newDate= new Date();

public void init()
{
add(dbutton1);
add(dbutton2);
add(quit);
}

public boolean action(Event evt, Object obj)
{
if (evt.arg=="Date 1")
Msg=newDate.toString();
else if (evt.arg=="Date 2")
Msg=newDate.getHours() + ":" +
newDate.getMinutes() + " " +
newDate.getDay() + "/" +
newDate.getMonth() + "/" +
newDate.getYear();
else if (evt.arg=="Quit") System.exit(0);
repaint();
return true;
}
public void paint(Graphics g)
{
if (Msg!=null)
g.drawString(Msg,20,100);
}
}

 

 

Figure 1: Pocket PC viewer of Flash movies