rajun87
Messages postés2Date d'inscriptionjeudi 4 juin 2015StatutMembreDernière intervention 4 juin 2015
-
4 juin 2015 à 08:27
rajun87
Messages postés2Date d'inscriptionjeudi 4 juin 2015StatutMembreDernière intervention 4 juin 2015
-
4 juin 2015 à 08:29
Bonjour,
je suis encore novice en JavaME, c'est pourquoi j'ai réalisé un petit calculette,mais cela ne fonctionne pas alors qu'il n'y a pas d'erreur sur le code. c'est sur l'émulateur qu'il y a un problème, il me dit:" Application start failed".
Voici mon code:
public class CalculatriceRajunJavaME extends MIDlet implements CommandListener {
private Form frmMain;
private Image imgAlert;
private TextField txfNumber1;
private TextField txfNumber2;
private StringItem stritemResult;
private ChoiceGroup chgOperation;
private Alert mAlert;
private Command cmdExit;
private Command cmdCalculate;
private final String strTitle = "Calculator";
private final String strNumber1 = "1st number:";
private final String strNumber2 = "2nd number:";
private final String strOperation = "Operation:";
private final String strResult = "Result:";
private final String strPathAlert = "/image/alert.png";
private final String strExit = "Exit";
private final String strCalculate = "Calculate";
private final String strTitleAlert = "Message";
private final String strMessageConvNumb = "The number is incorrect.";
private final String strMessageDivByZero = "It is not possible the division by zero.";
private final String[] strOperationName = new String[]
{ "Addition", "Subtraction", "Multiplication", "Division" };
private final String[] strPathImage = new String[]
{ "/image/plus.png", "/image/moins.png",
"/image/multi.png", "/image/div.png" };
private final Image[] imgOperationImage = new Image[4];
// Declaration of attributs for the calcule
private double dNumber1;
private double dNumber2;
private double dResult;
private int iOperation;
public void startApp() {
initComponents();
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
notifyDestroyed();
}
public void initComponents() {
frmMain = new Form(strTitle);
txfNumber1 = new TextField(strNumber1,"",10,TextField.ANY);
txfNumber2 = new TextField(strNumber2,"",10,TextField.ANY);
try {
for(int i = 0; i < strPathImage.length; i++) {
imgOperationImage[i] = Image.createImage(strPathImage[i]);
}
chgOperation = new ChoiceGroup (strOperation, Choice.EXCLUSIVE,
strOperationName, imgOperationImage);
} catch(IOException ioe) {
chgOperation = new ChoiceGroup (strOperation, Choice.EXCLUSIVE,
strOperationName, null);
}
stritemResult = new StringItem(strResult,"");
cmdExit = new Command(strExit, Command.EXIT, 1);
cmdCalculate = new Command(strCalculate, Command.OK, 1);
frmMain.append(txfNumber1);
frmMain.append(chgOperation);
frmMain.append(txfNumber2);
frmMain.append(stritemResult);