import java.awt.*;public class Memo extends Frame{ public String motd;
public Memo(String s){ //set our title super("Memo Frame");
motd = s; resize(300,300); } public Memo(){ this("This is a Memo"); }
public void paint(Graphics g){ g.drawString(motd,15,15); g.drawString("Click anywhere to Exit",15,25); } public void start(){ show(); }
public boolean mouseDown(Event e,int x,int y){ //hide the window hide(); //free up system resources dispose(); //quit the app System.exit(0); return false; } public static void main(String args[]) { Memo m; if(args.length>0){ m = new Memo(args[0]); } else{ m = new Memo(); } m.start(); } } 修改过,这个OK
鼠标事件没有加MouseListener,而且AWT event里也没有mousedown这个事件。还有很多小问题,建议换一本书看。
public String motd;
public Memo(String s){
//set our title
super("Memo Frame");
motd = s;
resize(300,300);
}
public Memo(){
this("This is a Memo");
}
public void paint(Graphics g){
g.drawString(motd,15,15);
g.drawString("Click anywhere to Exit",15,25);
}
public void start(){
show();
}
public boolean mouseDown(Event e,int x,int y){
//hide the window
hide();
//free up system resources
dispose();
//quit the app
System.exit(0);
return false;
} public static void main(String args[])
{
Memo m;
if(args.length>0){
m = new Memo(args[0]);
}
else{
m = new Memo();
}
m.start();
}
}
修改过,这个OK
你改的程序好象就加了一个0
我用下面的语句编译:
javac Memo.java
出现下面的提示:
Note: Memo.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.
你能不能不帮我写的具体一点啊
补充:你改过的程序可以编译运行,只是我不明白那两句提示是什么意思,你就帮我解释一下它好了,谢谢~~
Note: Recompile with -deprecation for details.
这个只是警告,是说界面上覆盖了一个不推荐使用的做法