I have made a interface in Java to translate from Spanish to English but my program have a error and I don't know why, please help me

199 views
Skip to first unread message

Mendoziya Mendo

unread,
Jan 29, 2013, 11:31:38 AM1/29/13
to microsoft-tran...@googlegroups.com
This is my code:


import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

import com.memetix.mst.language.Language;
import com.memetix.mst.translate.Translate;

public class prueba1 extends JFrame {
JButton English,Spanish;
JTextField textTranslate,resultTranslate;
public prueba1(){
setTitle("Translate");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new BorderLayout());
JPanel p1 = new JPanel();
p1.setLayout(new GridLayout(1,2));
textTranslate = new JTextField();
resultTranslate = new JTextField();
p1.add(textTranslate);
p1.add(resultTranslate);
add(p1, BorderLayout.CENTER);
JPanel p2 = new JPanel();
p2.setLayout(new GridLayout(1,2));
English = new JButton ("English - Spanish");
Spanish = new JButton("Spanish - English");
p2.add(English);
English.addActionListener(new OyenteBoton());
p2.add(Spanish);
add(p2, BorderLayout.SOUTH);
setSize(400, 250);
setVisible(true);

}

public static void main (String args[])throws Exception {
   prueba1 prueba1 = new prueba1();
}
class OyenteBoton implements ActionListener {
public void actionPerformed(ActionEvent e){
Translate.setClientId("xxxxxxxxxxxx");
Translate.setClientSecret("xxxxxxxxxxxxxxxxxxxxxx");
   String valor = textTranslate.getText();
   String translatedText = Translate.execute(valor, Language.SPANISH, Language.ENGLISH);   //<---- the error  is here
           resultTranslate.setText(translatedText);
   
  
}
}
}

this is the error:

Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problem: 
Unhandled exception type Exception

at prueba1$OyenteBoton.actionPerformed(prueba1.java:70)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$200(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Mendoziya Mendo

unread,
Jan 29, 2013, 11:34:04 AM1/29/13
to microsoft-tran...@googlegroups.com
This way I don't have problem:


import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import com.memetix.mst.language.Language;
import com.memetix.mst.translate.Translate;

public class prueba extends JFrame {

public static void main (String args[])throws Exception {
        
Translate.setClientId("xxxxxxx");
Translate.setClientSecret("xxxxxxxxxxxxxxxx");

String translatedText = Translate.execute("yo tengo 5 años", Language.SPANISH, Language.ENGLISH);
System.out.println("French -> English : " + translatedText);
}
}
 

Naveen Chitluri

unread,
Feb 8, 2013, 1:09:18 PM2/8/13
to microsoft-tran...@googlegroups.com
We receive a flat file from which has to be translated from Portugese to English.

Once I use this API, should I be bothered about any licensing issues couple of years down the line?
Reply all
Reply to author
Forward
0 new messages