当前位置: 技术问答>java相关
请问,以下有什么问题
来源: 互联网 发布时间:2015-10-22
本文导语: import java.awt.*; import java.applet.*; public class Button3 extends Applet { Button b1 = new Button("Button 1"), b2 = new Button("Button 2"); public void init() { add(b1); add(b2); } public boolean action (Eve...
import java.awt.*;
import java.applet.*;
public class Button3 extends Applet {
Button
b1 = new Button("Button 1"),
b2 = new Button("Button 2");
public void init() {
add(b1);
add(b2);
}
public boolean action (Event evt, Object arg) {
if(arg.equals("Button 1"))
getAppletContext().showStatus("Button 1");
else if(arg.equals("Button 2"))
getAppletContext().showStatus("Button 2");
// Let the base class handle it:
else
return super.action(evt, arg);
return true; // We've handled it here
}
} ///:~
我编辑时
javac Button2.java -depreccation
时出错
Button2.java:12: warning: action(java.awt.Event,java.lang.Object) in java.awt.Co
mponent has been deprecated
public boolean action(Event evt, Object arg) {
^
Button2.java:19: warning: action(java.awt.Event,java.lang.Object) in java.awt.Co
mponent has been deprecated
return super.action(evt, arg);
^
2 warnings
import java.applet.*;
public class Button3 extends Applet {
Button
b1 = new Button("Button 1"),
b2 = new Button("Button 2");
public void init() {
add(b1);
add(b2);
}
public boolean action (Event evt, Object arg) {
if(arg.equals("Button 1"))
getAppletContext().showStatus("Button 1");
else if(arg.equals("Button 2"))
getAppletContext().showStatus("Button 2");
// Let the base class handle it:
else
return super.action(evt, arg);
return true; // We've handled it here
}
} ///:~
我编辑时
javac Button2.java -depreccation
时出错
Button2.java:12: warning: action(java.awt.Event,java.lang.Object) in java.awt.Co
mponent has been deprecated
public boolean action(Event evt, Object arg) {
^
Button2.java:19: warning: action(java.awt.Event,java.lang.Object) in java.awt.Co
mponent has been deprecated
return super.action(evt, arg);
^
2 warnings
|
不是出错,只是不推荐使用而已