I created menu for mobile phone, where after you make move screen should be repainted and after that a sound should be played. However at present stage sound is played first and just after that Canvas view is repainted. Bellow is skeleton of the class
public class ContactMenu extends Canvas implements CommandListener
{
public ContactMenu()
{
backCommand = new Command("Back", Command.BACK, 0);
addCommand(backCommand);
selectCommand = new Command("Select", Command.SCREEN, 2);
addCommand(selectCommand);
setCommandListener(this);
backImg = il.loadImage("se_logo2.jpg");
}
public void paint(Graphics g)
{
//All drawing activities
playSelected();
}
public void commandAction(Command c, Displayable d)
{
if(lastCmd.equals(c.getLabel()))
{
if (c == backCommand)
{
}
}
else
{
lastCmd = c.getLabel();
tts.setSoundURL(lastCmd.toLowerCase());
tts.playSound("soundURL");
}
}
protected void keyPressed(int keyCode)
{
String str = getKeyName(keyCode);
if(str.equals("Up") || str.equals("UP"))
{
cml.moveSelection(-1);
repaint();
}
if(str.equals("Down") || str.equals("DOWN"))
{
cml.moveSelection(1);
repaint();
}
}
public void playSelected()
{
}
public void playSelected(String str)
{
}
}
I tried to move playSelected() at the end of keyPressed(), however this made no change to processing. Any suggestions how to tackle this issue?