JMU
The J2ME Mobile Information Device Profile
An Introduction


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu


What the MIDP Adds (to the Configuration)
Applications
Important Differences - Visual Content
Important Differences - Auditory Content
The MIDlet Lifecycle

images/midlet-lifecycle.gif
Developing User Interfaces

Important Components

images/j2me-gui.gif
Developing User Interfaces (cont.)

An Example of Form Layout

j2meexamples/src/phoneycall/MultipleCallScreen.java (Fragment: layout)
                form = new Form("Multiple Call Details");
        
        number = new TextField("No. of Calls:", "6", 6, TextField.NUMERIC);
        number.setLayout(Item.LAYOUT_EXPAND|Item.LAYOUT_NEWLINE_AFTER);
        form.append(number);
        
        interval = new TextField("In the next (sec.):", "120", 6, TextField.NUMERIC);
        interval.setLayout(Item.LAYOUT_EXPAND|Item.LAYOUT_NEWLINE_AFTER);
        form.append(interval);
        
        delay = new TextField("First call in (sec.):", "5", 3, TextField.NUMERIC);
        delay.setLayout(Item.LAYOUT_EXPAND|Item.LAYOUT_NEWLINE_AFTER);
        form.append(delay);
        
Developing User Interfaces (cont.)

An Example of a List

j2meexamples/src/phoneycall/CallersScreen.java (Fragment: layout)
                list = new List("Select Caller(s)", List.MULTIPLE);
        list.append("Aboutabl, Mohamed", null);
        list.append("Abzug, Charles", null);
        list.append("Adams, Elizabeth", null);
        list.append("Bernstein, David", null);
        list.append("Buchholz, Florian", null);
        list.append("Cushman, Pauline", null);
        list.append("Daughtrey, Taz", null);
        list.append("Fox, Christopher", null);
        list.append("Grove, Ralph", null);
        list.append("Harris, J. Archer", null);
        list.append("Harris, Nancy", null);
        list.append("Heydari, M. Hossain", null);
        list.append("Lane, Malcolm", null);
        list.append("Marchal, Joseph", null);
        list.append("Mata-Toledo, Ramon", null);
        list.append("Norton, Michael", null);
        list.append("Prieto-Díaz, Rubén", null);
        list.append("Redwine, Samuel", null);
        list.append("Tjaden, Brett", null);
        list.append("Wang, Xunhua (Steve)", null);
        
Developing User Interfaces (cont.)

Command Objects

images/j2me-gui-commands.gif
Developing User Interfaces (cont.)

Command Objects on a Form

j2meexamples/src/phoneycall/MultipleCallScreen.java (Fragment: commands)
                form.addCommand(CANCEL_COMMAND);
        form.addCommand(OK_COMMAND);
        
Developing User Interfaces (cont.)

A Select Command on a List

j2meexamples/src/phoneycall/CallCountScreen.java (Fragment: commands)
                list.setSelectCommand(SELECT_COMMAND);
        
Developing User Interfaces (cont.)

Handling Commands - The CommandListener Interface

j2meexamples/src/phoneycall/PhoneyCall.java (Fragment: commandlistener)
            /**
     * Handle a Command
     *
     * @param c   The Command
     * @param d   The Displayable that generated the Command
     */
    public void commandAction(Command c, Displayable d)
    {
        String   ac;
        
        ac = c.getLabel();
        
        if (ac.equals(AbstractState.CANCEL))
            state.handleCancel();
        if (ac.equals(AbstractState.OK))
            state.handleOK();
        if (ac.equals(AbstractState.SELECT))
            state.handleSelect();
    }