站内搜索: 请输入搜索关键词

当前页面: 开发资料首页J2ME 专题老出错 Client is not abstract and does not override abstract method destroyApp(boolean) in javax.mic

老出错 Client is not abstract and does not override abstract method destroyApp(boolean) in javax.mic

摘要: 老出错 Client is not abstract and does not override abstract method destroyApp(boolean) in javax.mic


我用的是netbeens 4.1 编译的时候老出现E:/luohong/bank/src/Client.java:7: Client is not abstract and does not override abstract method destroyApp(boolean) in javax.microedition.midlet.MIDlet
这个错误 哪位高手能帮忙解决下啊 谢谢

具体代码:
import java.io.*;
import java.lang.*;
import javax.microedition.io.*;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

public class Client extends MIDlet implements CommandListener
{
//连接url
private static String url="http://localhost:8080/a/b";
Display display;
Command exitCommand = new Command("退出",Command.EXIT,1);
Command okCommand = new Command("选择",Command.OK,1);
Command sendCommand = new Command("发送",Command.OK,1);
Command backCommand = new Command("返回",Command.BACK,0);

private TextBox entryPasswordForm;

public Client(){}
public void exitMIDlet()
{
notifyDestroyed();
}
protected void destroyAPP(boolean unconditional) throws MIDletStateChangeException
{
exitMIDlet();
}
protected void pauseAPP(){}
protected void startAPP(){
if(display == null){
display = Display.getDisplay(this);
Form contain_Form = new Form("Contain Form");
List menu;
TextBox input;
display = Display.getDisplay(this);
menu = new List("Select",Choice.IMPLICIT);
menu.append("Found",null);
menu.append("Delete",null);
menu.append("Update",null);

menu.addCommand(backCommand);
menu.addCommand(okCommand);
menu.setCommandListener(this);
menu.setCommandListener(this);
display.setCurrent(menu);
}
}
public void commandAction(Command c, Displayable d){
if(c == sendCommand){
StatusForm form_Status = new StatusForm(entryPasswordForm.getString());
display.setCurrent(form_Status);
form_Status.start();
}

else if(c == okCommand){
entryPasswordForm = new entryPasswordForm();
display.setCurrent(entryPasswordForm);
}

else{
exitMIDlet();
}
}

class entryPasswordForm extends TextBox{
entryPasswordForm(){
super("Enter your password:","",6,TextField.PASSWORD);
addCommand(backCommand);
addCommand(sendCommand);
setCommandListener(Client.this);
}
}

class StatusForm extends Form implements Runnable,MyHttpConnection.Callback{
StatusForm(String text){
super("Status");

try{
ByteArrayOutputStream byte_Out = new ByteArrayOutputStream();
DataOutputStream data_Out = new DataOutputStream(byte_Out);
data_Out.writeUTF(text);
data = byte_Out.toByteArray();
data_Out.close();
}
catch(IOException e){}
}

void display(String text){
if(message == null){
message = new StringItem(null,text);
append(message);
}
else{
message.setText(text);
}
}
void done(String msg){
display(msg != null ? msg:"Done.");
addCommand(okCommand);
addCommand(exitCommand);
setCommandListener(Client.this);
}
public void prep_Request(String originalURL,HttpConnection httpConn) throws IOException{
httpConn.setRequestMethod(HttpConnection.POST);
httpConn.setRequestProperty("Client-Agent","Profile/MIDP-1.0 Configuration/CLDC-1.0");
httpConn.setRequestProperty("Content-Language","en-US");
httpConn.setRequestProperty("Accept","application/ontet-stream");
httpConn.setRequestProperty("Connection","close");
httpConn.setRequestProperty("Content-Length",Integer.toString(data.length));
OutputStream output_stream = httpConn.openOutputStream();
output_stream.write(data);
output_stream.close();
}
public void run(){
HttpConnection httpConn = null;
display("Obtaining Connection from Server……");
try {
httpConn = MyHttpConnection.connect(url,this);
display("Connection to Server……");
int response_Code = httpConn.getResponseCode();
if(response_Code == HttpConnection.HTTP_OK)
{
StringBuffer text = new StringBuffer();

try{
DataInputStream data_In = new DataInputStream(httpConn.openInputStream());
int number = data_In.readInt();
while(number 0)
{
text.append(data_In.readUTF());
text.append('/n');
}
}
catch(IOException e){}
done("Your fond is : " + text.toString());
}
else {
done("Unexpected return code: " + response_Code);
}
}
catch(IOException e) {
done("Exception " + e + "trying to connect");
}
}

void start() {
display("Start to Connect to Server……");
Thread thread1 = new Thread(this);
try{
thread1.start();
}
catch(Exception e){
done("Exception" + e + "Trying to start thread.");
}
}
private StringItem message;
private byte[] data;
}

}









import java.io.*;
import javax.microedition.io.*;

public class MyHttpConnection
{
public interface Callback
{
void pre_Request(String originalURL, HttpConnection http_Con) throws IOException;
}

public static HttpConnection connect(String url) throws IOException
{
return connect(url, null);
}

public static HttpConnection connect(String url, Callback call) throws IOException
{
HttpConnection http_Con = null;
String original_URL = url;

while(url!=null)
{
http_Con = (HttpConnection)Connector.open(url);

if(call!=null)
{
call.pre_Request(original_URL, http_Con);
}

int rcode = http_Con.getResponseCode();

switch(rcode)
{
case HttpConnection.HTTP_MOVED_PERM:
case HttpConnection.HTTP_MOVED_TEMP:
case HttpConnection.HTTP_SEE_OTHER:
case HttpConnection.HTTP_TEMP_REDIRECT:

url = http_Con.getHeaderField("Location");
if(url!=null && url.startsWith("/*"))
{
StringBuffer buff = new StringBuffer();
buff.append("http://");
buff.append(http_Con.getHost());
buff.append(':');
buff.append(http_Con.getPort());
buff.append(url);
url = buff.toString();

}

http_Con.close();
break;
default:
url = null;
break;
}
}

return http_Con;
}
}



destroyApp() 你方法名写错了


destroyAPP
区分大小写的哦
应该是destroyApp


呵呵! 谢谢各位高手问题解决了


↑返回目录
前一篇: 请教关于midlet界面显示问题。
后一篇: 用Carbide.j需要使用verified 吗?