我正在爲圖書館管理系統創建一個登錄頁面。在下面的代碼片段中,我得到了一個沒有發現異常的類。但我不明白它在說什麼類,爲什麼是這個發生異常。此外,HomeStudent類已經定義,工作區中的所有類都位於同一個文件夾中。不理解類沒有發現異常
import java.awt.Button;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.Label;
import java.awt.Panel;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class MainClass extends Frame implements ActionListener {
static MainClass instance ;
Panel p = new Panel(new FlowLayout());
Label uname = new Label("UserName");
Label pass = new Label("Password");
TextField tuname = new TextField(10);
TextField tpass = new TextField(10);
Button login = new Button("GO");
public MainClass()
{
p.add(uname);
p.add(tuname);
p.add(pass);
p.add(tpass);
p.add(login);
login.addActionListener(this);
}
public static void main(String[] args)
{
instance = new MainClass();
instance.setVisible(true);
instance.setSize(new Dimension(100,100));
}
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
//DataBase Part
//Presently Done Simply
//Simple If Else
//Onlu Used for Prototyping
if(tuname.getText().equals("user")&&(tpass.getText().equals("user")))
{
HomeStudent home = new HomeStudent();
instance.setVisible(false);
home.setVisible(true);
home.setSize(new Dimension(100,100));
}
}
}
下面是堆棧跟蹤。
load: class .class not found.
java.lang.ClassNotFoundException: .class
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadCode(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
請問您可以添加堆棧跟蹤。 – midhunhk
請添加完整的錯誤消息。 – shofee
您的班級'HomeStudent'在哪裏指定?我希望你沒有爲那個獲得'ClassNotFoundException'。 – midhunhk