Y my interface is not showing when i run the project

Posted by Nubkadiya on Stack Overflow See other posts from Stack Overflow or by Nubkadiya
Published on 2010-05-17T06:08:14Z Indexed on 2010/05/17 6:10 UTC
Read the original article Hit count: 326

Filed under:
|

i have configured the Sphinx and i have used Main thread to do the recognition part. so that i can avoid the buttons. so currently my design is when the application runs it will check any voice recognition and prompt in the labels.

but when i run the project it dont display the interface of the application. only the frame shows. here is the code. if you guys can provide me with any solution for this. it will be great.

/*

* To change this template, choose Tools | Templates * and open the template in the editor. */

/* * FinalMainWindow.java * * Created on May 17, 2010, 11:22:29 AM */

package FYP;

import edu.cmu.sphinx.frontend.util.Microphone; import edu.cmu.sphinx.recognizer.Recognizer; import edu.cmu.sphinx.result.Result; import edu.cmu.sphinx.util.props.ConfigurationManager; //import javax.swing.; //import java.io.;

public class FinalMainWindow extends javax.swing.JFrame{

 Recognizer recognizer;

private void allocateRecognizer() {

    ConfigurationManager cm;

    cm = new ConfigurationManager("helloworld.config.xml");
    this.recognizer = (Recognizer) cm.lookup("recognizer");

    this.recognizer.allocate();

    Microphone microphone = (Microphone) cm.lookup("microphone");// TODO add
                                                               // your


    if (!microphone.startRecording()) {
 // System.out.println("Cannot start microphone.");

    //this.jlblDest.setText("Cannot Start Microphone");
   // this.jprogress.setText("Cannot Start Microphone");
        System.out.println("Cannot Start Microphone");
    this.recognizer.deallocate();

        System.exit(1);

    }

}

 boolean allocated;

// property file eka....... //code.google.com

private void voiceMajorInput()
{

     if (!allocated) {
           this.allocateRecognizer();
           allocated = true;
    }

    Result result = recognizer.recognize();

    if (result != null) {

        String resultText = result.getBestFinalResultNoFiller();
        System.out.println("Recognized Result is " +resultText);
        this.jhidden.setText(resultText);
}
}
/** Creates new form FinalMainWindow */
public FinalMainWindow() {
    initComponents();
}

/** This method is called from within the constructor to
 * initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

    jhidden = new javax.swing.JLabel();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

    jhidden.setText("jLabel1");

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addGap(51, 51, 51)
            .addComponent(jhidden)
            .addContainerGap(397, Short.MAX_VALUE))
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addGap(45, 45, 45)
            .addComponent(jhidden)
            .addContainerGap(293, Short.MAX_VALUE))
    );

    pack();
}// </editor-fold>

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {

       //      new FinalMainWindow().setVisible(true);

            FinalMainWindow mw = new FinalMainWindow();

            mw.setVisible(true);

            mw.voiceMajorInput();

            new FinalMainWindow().setVisible(true);
        }
    });
}

// Variables declaration - do not modify
private javax.swing.JLabel jhidden;
// End of variables declaration

}

© Stack Overflow or respective owner

Related posts about java

Related posts about sphinx