我编写了五个类,简而言之,它们的目的是为会议创建 GUI 和记录参与者。我已经构建了面板并添加了它们,FocusListeners、ActionListeners、ItemListeners。
据我所知,我在崩溃时收到的消息与我的类路径有关,但我真的不知道如何修复它。这是发生崩溃的代码(当我为面板的两个按钮添加 ActionListeners 时:
private void buildButtonPanel()
{
//create the buttonpanel
buttonPanel = new JPanel(new FlowLayout());
//create the buttons
calculate = new JButton("Calculate Charges");
clear = new JButton ("Clear");
//add listeners to the buttons
ConferenceHandler handler = new ConferenceHandler(this);
calculate.addActionListener(handler); //crash occurs on this line
clear.addActionListener(handler);
//create a text area
JTextArea textArea = new JTextArea(5,30);
textArea.setLineWrap(true); textArea.setWrapStyleWord(true);
//add a scrollbar to the textarea
JScrollPane scroll = new JScrollPane (textArea);
//add everything to the buttonpanel
buttonPanel.add(calculate); buttonPanel.add(clear); buttonPanel.add(scroll);
}
我收到的崩溃消息:
java.lang.NoClassDefFoundError: ConferenceHandler
at ConferenceGUI.buildButtonPanel(ConferenceGUI.java:63)
at ConferenceGUI.<init>(ConferenceGUI.java:33)
at IsItWorking.<init>(IsItWorking.java:16)
at IsItWorking.main(IsItWorking.java:28)
Caused by: java.lang.ClassNotFoundException: ConferenceHandler
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at ConferenceGUI.buildButtonPanel(ConferenceGUI.java:63)
at ConferenceGUI.<init>(ConferenceGUI.java:33)
at IsItWorking.<init>(IsItWorking.java:16)
at IsItWorking.main(IsItWorking.java:28)
at __SHELL0.run(__SHELL0.java:6)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at bluej.runtime.ExecServer$3.run(ExecServer.java:774)
我知道这里有很多经验丰富的人,我在互联网上找不到任何关于这方面的帮助。