đây là code của mình
Mã:
import javax.microedition.midlet.*;import javax.microedition.lcdui.*; public class Midlet extends MIDlet implements CommandListener { private Display display; private Form fnMain; private Command cmExit; private Command cmOK; private Command cmReset; private TextField txta; private TextField txtb; private TextField txtPhepToan; private TextField txtc; public Midlet() { display=Display.getDisplay(this); cmExit=new Command("Exit", Command.EXIT,1); cmOK=new Command("Reset",Command.SCREEN,2); txta=new TextField("a=","",10,2); txtb=new TextField("b=","",10,2); txtPhepToan=new TextField("Phép tóan","",1,0); txtc=new TextField("ket quả c=","",10,2); fnMain=new Form("Bài Thực Hành 1.1"); fnMain.append(txta); fnMain.append(txtPhepToan); fnMain.append(txtb); fnMain.append(txtc); fnMain.addCommand(cmOK); fnMain.addCommand(cmExit); fnMain.addCommand(cmReset); fnMain.setCommandListener(this); } public void startApp() { display.setCurrent(fnMain); } public void commandAction(Command c,Displayable s) { if(c==cmExit) { destroyApp(false); notifyDestroyed(); } else if(c==cmOK) { String str=new String(); str=txta.getString(); int a=Integer.parseInt(str); str=txtb.getString(); int b=Integer.parseInt(str); int Ketqua=0; str=txtPhepToan.getString(); switch(str.charAt(0)) { case'+':Ketqua=a+b;break; case'-':Ketqua=a-b;break; case'x':Ketqua=a*b;break; case'/':Ketqua=a/b;break; default: System.out.println("nhap phep toan sai"); } if(Ketqua!=0) { str=Integer.toString(Ketqua); txtc.setString(str); } else if(c==cmReset) { txta.setString(""); txtb.setString(""); txtPhepToan.setString(""); txtc.setString(""); } } } public void pauseApp() { } public void destroyApp(boolean unconditional) { }}
đây là lỗi khi chạy chương trình
[IMG]http:/r0.upanh.com/b1.s34.d4/743a243a95e1efa8c2e9a830a7d600eb_50439600.j2me.png[/IMG]
View more random threads:
Pallet nhựa Lâm Đồng giải pháp hoàn hảo cho nhà kho Pallet nhựa Lâm Đồng là một giải pháp đa năng và hiệu quả trong việc vận chuyển và lưu trữ hàng hóa. Trong đó, pallet nhựa Lâm Đồng không chỉ đáp...
Pallet nhựa Lâm Đồng giải pháp...