代碼如下,提示"cannot be resolved to type"(已在注釋中標出),但我認為沒有問題啊
package QAppLet;
import java.awt.*;
import java.awt.event.*;
import java.awt.Button;
public class Complete {
public static void main(String[] args) {
MyFrame m=new MyFrame("字符比較器");
}
}
class MyFrame extends Frame{
MyFrame(String s){
super(s);
setVisible(true);
setLayout(new FlowLayout());
TextField f1=new TextField(50);
TextField f2=new TextField(50);
TextField f3=new TextField(10);
Label la1=new Label();
Label la2=new Label();
Label la3=new Label();
la1.setText("y原始值");
la2.setText("比較值");
la3.setText("比較結果");
Button b=new Button("確定");
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
setVisible(false);
System.exit(0);
}
});
add(la1);
add(f1);
add(la2);
add(f2);
add(la3);
f3.setEditable(false);
add(f3);
add(b);
b.addActionListener(new Act()); //提示“Act cannot be resolved to type"
class Act implements ActionListener{
public void actionPerformed(ActionEvent e){
if((f1.getText()).equals(f2.getText()))
f3.setText("相等");
else
f3.setText("不相等");
}
}
}
}