السلام عليكم
أنا أكتب أول برنامج لي للموبايل
أستخدم netbeans
كود البرنامج
/*
* HelloMidlet.java
*
* Created on 23 آب, 2006, 12:06 م
*/
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
/**
*
* @author user
*/
public class HelloMidlet extends MIDlet implements CommandListener, ItemCommandListener {
/** Creates a new instance of HelloMidlet */
public HelloMidlet() {
}
private Form helloForm;
private StringItem helloStringItem;
private Command exitCommand;
private Form frmmain;
private Command screenCommand1;
private Command screenCommand2;
private Command exitCommand1;
private Image image1;
private ImageItem imageItem1;
private TextField txtf1;
private Command okCommand1;
private Alert alert1;
private Alert alert2;
private Command backCommand1;
private Command backCommand2;
private Command backCommand3;
private Command backCommand4;
/** Called by the system to indicate that a command has been invoked on a particular item.
* @param command the Command that ws invoked
* @param item the Item on which the command was invoked
*/
public void commandAction(Command command, Item item) {
// Insert global pre-action code here
if (item == txtf1) {
if (command == okCommand1) {
if (txtf1.getString()=="kkk"){
getDisplay().setCurrent(get_alert1());};
// Do nothing
// Insert post-action code here
}
}
// Insert global post-action code here
}
/** This method initializes UI of the application.
*/
private void initialize() {
// Insert pre-init code here
getDisplay().setCurrent(get_helloForm());
// Insert post-init code here
}
/** Called by the system to indicate that a command has been invoked on a particular displayable.
* @param command the Command that ws invoked
* @param displayable the Displayable on which the command was invoked
*/
public void commandAction(Command command, Displayable displayable) {
// Insert global pre-action code here
if (displayable == helloForm) {
if (command == exitCommand) {
// Insert pre-action code here
exitMIDlet();
// Insert post-action code here
} else if (command == screenCommand2) {
// Insert pre-action code here
getDisplay().setCurrent(get_frmmain());
// Insert post-action code here
}
} else if (displayable == frmmain) {
if (command == exitCommand1) {
// Insert pre-action code here
exitMIDlet();
// Insert post-action code here
}
} else if (displayable == alert2) {
if (command == backCommand4) {
// Insert pre-action code here
getDisplay().setCurrent(get_frmmain());
// Insert post-action code here
}
} else if (displayable == alert1) {
if (command == backCommand2) {
// Insert pre-action code here
getDisplay().setCurrent(get_helloForm());
// Insert post-action code here
}
}
// Insert global post-action code here
}
/**
* This method should return an instance of the display.
*/
public Display getDisplay() {
return Display.getDisplay(this);
}
/**
* This method should exit the midlet.
*/
public void exitMIDlet() {
getDisplay().setCurrent(null);
destroyApp(true);
notifyDestroyed();
}
/** This method returns instance for helloForm component and should be called instead of accessing helloForm field directly.
* @return Instance for helloForm component
*/
public Form get_helloForm() {
if (helloForm == null) {
// Insert pre-init code here
helloForm = new Form(null, new Item[] {get_helloStringItem()});
helloForm.addCommand(get_exitCommand());
helloForm.addCommand(get_screenCommand2());
helloForm.setCommandListener(this);
// Insert post-init code here
}
return helloForm;
}
/** This method returns instance for helloStringItem component and should be called instead of accessing helloStringItem field directly.
* @return Instance for helloStringItem component
*/
public StringItem get_helloStringItem() {
if (helloStringItem == null) {
// Insert pre-init code here
helloStringItem = new StringItem("Hello", "Hello, World!");
// Insert post-init code here
}
return helloStringItem;
}
/** This method returns instance for exitCommand component and should be called instead of accessing exitCommand field directly.
* @return Instance for exitCommand component
*/
public Command get_exitCommand() {
if (exitCommand == null) {
// Insert pre-init code here
exitCommand = new Command("Exit", Command.EXIT, 1);
// Insert post-init code here
}
return exitCommand;
}
/** This method returns instance for frmmain component and should be called instead of accessing frmmain field directly.
* @return Instance for frmmain component
*/
public Form get_frmmain() {
if (frmmain == null) {
// Insert pre-init code here
frmmain = new Form(null, new Item[] {
get_imageItem1(),
get_txtf1()
});
frmmain.addCommand(get_exitCommand1());
frmmain.setCommandListener(this);
// Insert post-init code here
}
return frmmain;
}
/** This method returns instance for screenCommand1 component and should be called instead of accessing screenCommand1 field directly.
* @return Instance for screenCommand1 component
*/
public Command get_screenCommand1() {
if (screenCommand1 == null) {
// Insert pre-init code here
screenCommand1 = new Command("Screen", Command.SCREEN, 1);
// Insert post-init code here
}
return screenCommand1;
}
/** This method returns instance for screenCommand2 component and should be called instead of accessing screenCommand2 field directly.
* @return Instance for screenCommand2 component
*/
public Command get_screenCommand2() {
if (screenCommand2 == null) {
// Insert pre-init code here
screenCommand2 = new Command("Screen", Command.SCREEN, 1);
// Insert post-init code here
}
return screenCommand2;
}
/** This method returns instance for exitCommand1 component and should be called instead of accessing exitCommand1 field directly.
* @return Instance for exitCommand1 component
*/
public Command get_exitCommand1() {
if (exitCommand1 == null) {
// Insert pre-init code here
exitCommand1 = new Command("Exit", Command.EXIT, 1);
// Insert post-init code here
}
return exitCommand1;
}
/** This method returns instance for image1 component and should be called instead of accessing image1 field directly.
* @return Instance for image1 component
*/
public Image get_image1() {
if (image1 == null) {
// Insert pre-init code here
try {
image1 = Image.createImage("/Captcha.jpg");
} catch (java.io.IOException exception) {
}
// Insert post-init code here
}
return image1;
}
/** This method returns instance for imageItem1 component and should be called instead of accessing imageItem1 field directly.
* @return Instance for imageItem1 component
*/
public ImageItem get_imageItem1() {
if (imageItem1 == null) {
// Insert pre-init code here
imageItem1 = new ImageItem("\u0645\u0631\u062D\u0628\u0627", get_image1(), Item.LAYOUT_DEFAULT, null, javax.microedition.lcdui.Item.BUTTON);
// Insert post-init code here
}
return imageItem1;
}
/** This method returns instance for txtf1 component and should be called instead of accessing txtf1 field directly.
* @return Instance for txtf1 component
*/
public TextField get_txtf1() {
if (txtf1 == null) {
// Insert pre-init code here
txtf1 = new TextField("\u0627\u0643\u062A\u0628 \u0645\u0627 \u0641\u064A \u0627\u0644\u0635\u0648\u0631\u0629", "", 120, TextField.ANY);
txtf1.addCommand(get_okCommand1());
txtf1.setItemCommandListener(this);
// Insert post-init code here
}
return txtf1;
}
/** This method returns instance for okCommand1 component and should be called instead of accessing okCommand1 field directly.
* @return Instance for okCommand1 component
*/
public Command get_okCommand1() {
if (okCommand1 == null) {
// Insert pre-init code here
okCommand1 = new Command("Ok", Command.OK, 1);
// Insert post-init code here
}
return okCommand1;
}
/** This method returns instance for alert1 component and should be called instead of accessing alert1 field directly.
* @return Instance for alert1 component
*/
public Alert get_alert1() {
if (alert1 == null) {
// Insert pre-init code here
alert1 = new Alert(null, "\u0623\u062D\u0633\u0646\u062A\n\u0627\u0644\u0646\u062A\u064A\u062C\u0629 \u0635\u062D\u064A\u062D\u0629", null, AlertType.INFO);
alert1.addCommand(get_backCommand2());
alert1.setCommandListener(this);
alert1.setTimeout(-2);
// Insert post-init code here
}
return alert1;
}
/** This method returns instance for alert2 component and should be called instead of accessing alert2 field directly.
* @return Instance for alert2 component
*/
public Alert get_alert2() {
if (alert2 == null) {
// Insert pre-init code here
alert2 = new Alert(null, "\u0627\u0644\u0646\u062A\u064A\u062C\u0629 \u062E\u0627\u0637\u0626\u0629\n\u0623\u0639\u062F \u0627\u0644\u0645\u062D\u0627\u0648\u0644\u0629", null, AlertType.INFO);
alert2.addCommand(get_backCommand4());
alert2.setCommandListener(this);
alert2.setTimeout(-2);
// Insert post-init code here
}
return alert2;
}
/** This method returns instance for backCommand1 component and should be called instead of accessing backCommand1 field directly.
* @return Instance for backCommand1 component
*/
public Command get_backCommand1() {
if (backCommand1 == null) {
// Insert pre-init code here
backCommand1 = new Command("Back", Command.BACK, 1);
// Insert post-init code here
}
return backCommand1;
}
/** This method returns instance for backCommand2 component and should be called instead of accessing backCommand2 field directly.
* @return Instance for backCommand2 component
*/
public Command get_backCommand2() {
if (backCommand2 == null) {
// Insert pre-init code here
backCommand2 = new Command("Back", Command.BACK, 1);
// Insert post-init code here
}
return backCommand2;
}
/** This method returns instance for backCommand3 component and should be called instead of accessing backCommand3 field directly.
* @return Instance for backCommand3 component
*/
public Command get_backCommand3() {
if (backCommand3 == null) {
// Insert pre-init code here
backCommand3 = new Command("Back", Command.BACK, 1);
// Insert post-init code here
}
return backCommand3;
}
/** This method returns instance for backCommand4 component and should be called instead of accessing backCommand4 field directly.
* @return Instance for backCommand4 component
*/
public Command get_backCommand4() {
if (backCommand4 == null) {
// Insert pre-init code here
backCommand4 = new Command("Back", Command.BACK, 1);
// Insert post-init code here
}
return backCommand4;
}
public void startApp() {
initialize();
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
}المشكلة الأولى أني و ضعت شرط
if (txtf1.getString()=="kkk")
txtf1.getString
لاتعطي ما أكتبه عند تنفيذه
المشكلة الثانية أن البرنامج يعمل على المحاكي و لكن لايعمل على الخليوي بعدالتحزيم jar
و التنزيل على الخليوي
يعطي الرسالة التالية
هنالك خطأفي التحويل
اعذروني ان أثقلت عليكم
و السلام عليكم