import javax.microedition.lcdui.*;
public class ItemLink extends Canvas{
DemoMidlet demoRef;
int y_pos = 20;
int selected = 0;
// These are Key value.
public static final int KEY_UP = -1;
public static final int KEY_DOWN = -2;
public static final int KEY_SELECT = -5;
// Menu Item
static String menuArr[]={"1. One",
"2. Two",
"3. Three"};
public ItemLink(DemoMidlet demoRef){
this.demoRef = demoRef;
}
public void paint(Graphics g) {
for(int i=0;i<3;i++) {
// Here you can change GUI according to your Requirement
if(selected == i) {
g.setColor(0xff0055);
g.fillRect(6,(y_pos * i)+ 8,getWidth()-26,15);
}
else {
g.setColor(255,255,255);
g.fillRect(6,(y_pos * i)+ 8,getWidth()-26,15);
}
g.setColor(0x000000);
// Here you can aslo have the image ..
//g.drawImage(....);
g.drawString(menuArr, 10 , (y_pos * i)+ 8, 0 );
g.drawRect(5,(y_pos * i)+ 7,getWidth()-25,15);
}
}
public void traverse(){
}
public void keyPressed (int keyCode) {
System.out.println("keyCode " + keyCode);
switch (keyCode) {
case KEY_UP:
// Highlighting Previous Item
if(selected>0)
selected--;
repaint();
break;
case KEY_DOWN:
// Highlighting next Item
if(selected<2)
selected++;
repaint();
break;
case KEY_SELECT:
// here you can redirect your control to next form..
break;
}
}
}