-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIm.java
More file actions
56 lines (54 loc) · 1.16 KB
/
Im.java
File metadata and controls
56 lines (54 loc) · 1.16 KB
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
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class Im extends MIDlet
implements CommandListener
{
private Display display;
private Form form;
private Command exit;
private Image image;
private ImageItem imageItem;
public Im()
{
display = Display.getDisplay(this);
exit = new Command("Exit", Command.EXIT, 1);
form = new Form("Immutable Image Example");
form.addCommand(exit);
form.setCommandListener(this);
try
{
image = Image.createImage("/myimage.png");
imageItem = new ImageItem(null, image,
ImageItem.LAYOUT_NEWLINE_BEFORE |
ImageItem.LAYOUT_LEFT |
ImageItem.LAYOUT_NEWLINE_AFTER, "My Image");
form.append(imageItem);
}
catch (java.io.IOException error)
{
Alert alert = new Alert("Error", "Cannot load myimage.png.",
null, null);
alert.setTimeout(Alert.FOREVER);
alert.setType(AlertType.ERROR);
display.setCurrent(alert);
}
}
public void startApp()
{
display.setCurrent(form);
}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional)
{
}
public void commandAction(Command command, Displayable Displayable)
{
if (command == exit)
{
destroyApp(false);
notifyDestroyed();
}
}
}