2010-12-16 4 views
0

확인란의 색인을 추가 한 후 프로그램을 실행하지 못하는 이유는 무엇입니까? agreeIndex = mainForm.append (agree);확인란의 색인을 추가 한 후에 J2ME 프로그램을 실행하지 못했습니다.

import javax.microedition.midlet.*; 
import java.util.*; 
import javax.microedition.lcdui.*; 
public class MainPage extends MIDlet implements CommandListener, ItemStateListener{ 
Ticker header; 
Display display; 
Form mainForm; 
TextField name, num, phone, email, age; 
ChoiceGroup gender; 
private int choiceGroupIndex; 
Command nextCom, clearCom, exitCom; 
Page1 p1; 
ChoiceGroup agree = new ChoiceGroup("Please read the terms and conditions from menu." 
     , Choice.MULTIPLE); 
int agreeIndex; 

public MainPage(){ 
    header = new Ticker("**ABC Restraurant**Customer Survey**"); 
    mainForm = new Form("Personal Information"); 
    name = new TextField("User name: ", "", 20, TextField.ANY); 
    num = new TextField("User id: ", "", 10, TextField.NUMERIC); 
    phone = new TextField("Phone no.: ", "", 10, TextField.PHONENUMBER); 
    email = new TextField("E-mail: ", "", 20, TextField.ANY); 
    age = new TextField("Age: ", "", 3, TextField.NUMERIC); 
    gender = new ChoiceGroup("Gender: ", Choice.EXCLUSIVE); 
    nextCom = new Command("Next", Command.SCREEN, 1); 
    clearCom = new Command("Clear", Command.SCREEN, 2); 
    exitCom = new Command("Exit", Command.EXIT, 3); 
    p1 = new Page1(this); 


    mainForm.setTicker(header); 
    mainForm.append(name); 
    mainForm.append(num); 
    gender.append("Male", null); 
    gender.append("Female", null); 
    choiceGroupIndex = mainForm.append(gender); 
    mainForm.append(age); 
    mainForm.append(phone); 
    mainForm.append(email); 

    //agree.append("I agree with the terms and conditions.", null); 
    mainForm.append(agree); 

    mainForm.addCommand(nextCom); 
    mainForm.addCommand(clearCom); 
    mainForm.addCommand(exitCom); 
    mainForm.setCommandListener(this); 

} 

public void commandAction(Command c, Displayable s) { 
    if (c == exitCom) 
    { 
     try { 
     destroyApp(false); 
    } catch (MIDletStateChangeException e) { 
     e.printStackTrace(); 
    } 
     notifyDestroyed(); 
    } else if (c == clearCom) { 
     resetTransferInformation(); 
    } else if (c == nextCom) { 

     display.setCurrent(p1.list); 
     //System.out.print(agreeIndex); 
    } 

} 

protected void destroyApp(boolean arg0) throws MIDletStateChangeException { 

} 

protected void pauseApp() { 


} 

protected void startApp() throws MIDletStateChangeException { 
    display = Display.getDisplay(this); 
    display.setCurrent(mainForm); 
    agree.append("I agree with the terms and conditions.", null); 
    agreeIndex = mainForm.append(agree); 

} 

public void itemStateChanged(Item item)    
    { 
    } 

public void resetTransferInformation() { 
    name.setString(""); 
    num.setString(""); 
    phone.setString(""); 
    email.setString(""); 
    age.setString(""); 
} 

public void back() { 
    display.setCurrent(mainForm); 
} 

} 
+0

무엇이 오류입니까? – aioobe

+0

에뮬레이터를 정상적으로 실행할 수 없으면 즉시 실행되고 종료됩니다. – Walter

답변

0

추가하려고하면 mainForm에 두 번 동의합니다. (생성자와 startApp에서)

정확하지 않습니다.

관련 문제