-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathP2_2.java
55 lines (48 loc) · 1.3 KB
/
P2_2.java
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
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class P2_2 extends MIDlet implements CommandListener{
private Display display;
private List list;
private Command select,exit;
public P2_2(){
super();
}
public void startApp(){
//2_2 is displaying the menu commandlisteners
display=Display.getDisplay(this);
list=new List("MENULIST",List.EXCLUSIVE);
list.append("cut",null);
list.append("copy",null);
list.append("paste",null);
list.append("delete",null);
list.append("select_all",null);
list.append("unselect_all",null);
select= new Command("SELECT",Command.OK,1);
exit=new Command("EXIT",Command.EXIT,1);
list.addCommand(select);
list.addCommand(exit);
list.setCommandListener(this);
display.setCurrent(list);
}
public void pauseApp(){
}
public void destroyApp(boolean unconditional){
notifyDestroyed();
}
public void commandAction(Command c, Displayable d){
if(c==exit){
destroyApp(false);
}
if(c==select){
String temp="You selected "+list.getString(list.getSelectedIndex());
if(list.getSelectedIndex()==4){
temp="You selected CUT, COPY, PASTE, DELETE";
}
if(list.getSelectedIndex()==5){
temp="You selected NONE";
}
Alert alert = new Alert("SELECTED OPTION",temp,null,null);
display.setCurrent(alert);
}
}
}