Regarding CustomItem in j2me

Hai all, I want to show the users presence, whether they are online or offline etc..How to insert the image using CustomItem control. please can anyone help me.. Thanks/RegardsB.krishnanMessage was edited by: Bkrishnan
[260 byte] By [Bkrishnana] at [2007-11-26 19:10:01]
# 1
in the paint method, you can draw an Image and a String (drawImage(...) and drawString(..)methods...).call the repaint() method to update the CustomItem
suparenoa at 2007-7-9 21:05:30 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 2

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;

}

}

}

prafull_14@rediffmail.coma at 2007-7-9 21:05:30 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 3
Hope the above code will help you, to reach you goal
prafull_14@rediffmail.coma at 2007-7-9 21:05:30 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 4
the OP was talkin about CustomItem not Canvas!these link may help him: http://developers.sun.com/techtopics/mobility/midp/articles/customitems/index.html http://developers.sun.com/techtopics/mobility/midp/ttips/customitem/
suparenoa at 2007-7-9 21:05:30 > top of Java-index,Java Mobility Forums,Java ME Technologies...