java中的Applet上面总是有一条横线。求帮助。谢谢大家!
老师给的程序没有主类,错误如下,不知道怎么改了!
警告: [options] 未与 -source 8 一起设置引导类路径
注: G:\JAVA实践\java\practice1\src\Basic\btnlabelaction.java使用或覆盖了已过时的 API。
注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。
1 个警告
compile-single:
run-applet:
错误: 找不到或无法加载主类 sun.applet.AppletViewer
原因: java.lang.ClassNotFoundException: sun.applet.AppletViewer
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class btnlabelaction extends Applet implements ActionListener{
Label prompt;
Button btn;
@Override
public void init(){
prompt = new Label();
btn = new Button();
add(prompt);
add(btn);
btn.addActionListener(this);
this.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource() == btn)
if("你好".equals(prompt.getText()))
prompt.setText("再见");
else
prompt.setText("你好");
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}