开发J2ME联网应用程序[6]

[入库:2006年2月23日] [更新:2007年3月24日]

本文简介:

    private void closeConnection(HttpConnection conn, DataInputStream dis,
            DataOutputStream dos)
    {
        if(conn!= null)
        {
            try
            {
                conn.close();
            }
            catch(IOException e)
            {}
        }
       
        if(dis!=null)
        {
            try
            {
                dis.close(); 
            }
            catch(IOException e)
            {}
        }
       
        if(dos!=null)
        {
            try
            {
                dos.close();
            }
            catch(IOException e)
            {}
        }
       
    }

}


import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.StringItem;


public class DisplayCanvas extends Form implements CommandListener
{
    private UIController uicontroller;
    private StringItem result;
    private int index = 0;
    private boolean first = true;
    public static Command backCommand = new Command("Back", Command.BACK, 2);

    public DisplayCanvas(UIController uicontroller)
    {
        super("Result");
        this.uicontroller = uicontroller;
        result = new StringItem("you have input:", null);
        this.addCommand(backCommand);
        this.setCommandListener(this);

    }

    public void init(String message)
    {
        if (first)
        {
            result.setText(message);
            index = this.append(result);
            first = false;
        }
        else
        {
            this.delete(index);
            result.setText(message);
            this.append(result);
        }

    }


    public void commandAction(Command arg0, Displayable arg1)
    {
        uicontroller.handleEvent(UIController.EventID.DISPLAY_BACK_TO_INPUT,
                null);

    }

}

本文关键:开发J2ME联网应用程序
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top