我正在为图书馆管理系统创建一个登录页面。在下面的代码中,我得到了一个找不到类的异常。但我不明白它在谈论哪个类以及为什么会发生这种异常。此外,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)