I'm doing speech recognition application. Now my application can recognize my speech command, but somehow my application still not working. Is it because i did not trigger an event like .getSource()? This is part of my program:
public void resultAccepted(javax.speech.recognition.ResultEvent e)
{
try{
Result r = (Result)(e.getSource());
ResultToken tokens[] = r.getBestTokens();
for (int i = 0; i < tokens.length; i++)
{
gst=tokens[i].getSpokenText();
}
JOptionPane.showMessageDialog(new JFrame(),gst, "word",JOptionPane.INFORMATION_MESSAGE);
if (gst.equals("A"))
{
try{
lesson_yearlist.show();
lesson_yearlist.toFront();
}
catch(Exception ee)
{
JOptionPane.showMessageDialog(new JFrame(),"error", "Error", JOptionPane.ERROR_MESSAGE);
}
}
else if (gst.equals("Exercise"))
{
JOptionPane.showMessageDialog(new JFrame(),"printing", "print",JOptionPane.INFORMATION_MESSAGE);
exelist.show();
exelist.toFront();
}
else
{
JOptionPane.showMessageDialog(new JFrame(),"error", "Not found",JOptionPane.ERROR_MESSAGE);
}
}
catch (Exception ec)
{
ec.printStackTrace();
}
}
When I say "exercise", the JOptionPane is showing "exercise" to show that the recognizer gets what i said exactly and the second JOptionPane shows "printing" to show that my if statement is working. But the second and third lines exelist.show() and exelist.toFront() are not working. They are working fine with button using mouse.
Please help. Thanks