Selasa, 09 Oktober 2012

ASSIGNMENT 4TH MEETING


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;


public class Assignment extends MIDlet implements CommandListener {
    Display display;
    Form forms, resultforms;
    Command exitCommand = new Command("Exit", Command.EXIT, 1);
    Command okCommand = new Command("OK", Command.OK, 2);
    Alert alert = new Alert("Error", "Ada yang belum diisi!!pleas isi kabeh!", null, AlertType.ERROR);
    TextField name, address, phonenumber, email;
    ChoiceGroup popup;
    DateField dateonly;
    StringItem result;
  
     

  
  
    public Assignment() {
        forms = new Form("Assignment 4th Meeting");
        forms.addCommand(exitCommand);
        forms.addCommand(okCommand);
      
             
        name = new TextField("Input Name", "", 64, TextField.ANY);
        popup = new ChoiceGroup("Gender", Choice.POPUP);
        address = new TextField("Input Address", "", 64, TextField.ANY);
        phonenumber = new TextField("Input PhoneNumber", "", 64, TextField.PHONENUMBER);
        email = new TextField("Inpur Email", "", 64, TextField.EMAILADDR);
        dateonly = new DateField("Birthday", DateField.DATE);
       
        forms.append(name);
        forms.append(popup);
        popup.append("Male", null);
        popup.append("Female", null);
        forms.append(address);
        forms.append(phonenumber);
        forms.append(email);
        forms.append(dateonly);
        forms.setCommandListener(this);
     
    }

    public void startApp() {
         if (display == null) {
               display = Display.getDisplay(this);
               display.setCurrent(forms);
          }
     
    }
  
    public void pauseApp() {
    }
  
    public void destroyApp(boolean unconditional) {
    }

    public void commandAction(Command c, Displayable d) {
        //throw new UnsupportedOperationException("Not supported yet.");
         //throw new UnsupportedOperationException("Not supported yet.");
        if (c == exitCommand) {
               destroyApp(true);
               notifyDestroyed(); //Exit
          }
      
      
        if(c == okCommand) {
            if((name.getString()).equals("") || (address.getString()).equals("") || phonenumber.getString().equals("")
                    || email.getString().equals("") ) {
                display.setCurrent(alert);
            }
         
            else {
                //dddforms.deleteAll();
                resultforms = new Form("Assignment 4th Meeting");
                result = new StringItem("", "Name: "+name.getString()+"\n"
                        +"Gender: "+popup.getString(popup.getSelectedIndex())+"\n"
                        +"Address: "+address.getString()+"\n"
                        +"PhoneNumber: "+phonenumber.getString()+"\n"
                        +"Email: "+email.getString()+"\n"
                        +"Birthday: "+dateonly.getDate()+"\n");
              
                resultforms.append(result);
                display = Display.getDisplay(this);
                display.setCurrent(resultforms);              
            }
        }
    }
  
  
    public void commandAction(Command c, Item item) {
        //throw new UnsupportedOperationException("Not supported yet.");
          
        }
      
    }





Tidak ada komentar:

Posting Komentar