我正在Netbeans 6.9中开发一个javadesktop应用程序,一切都很完美,但。。。它给了我一个错误:
@Action
public void showAboutBox()
{
if (aboutBox == null) {
JFrame mainFrame = Mp4App.getApplication().getMainFrame();
aboutBox = new mp4AboutBox(mainFrame);
aboutBox.setLocationRelativeTo(mainFrame);
}
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
这就是错误:
Compiling 1 source file to Q:Mp3 Appmp4-betamp4buildclasses
Q:Mp3 Appmp4-betamp4srcmp4Mp4View.java:223: cannot find symbol
symbol : class mp4AboutBox
location: class mp4.Mp4View
aboutBox = new mp4AboutBox(mainFrame);
1 error
Q:Mp3 Appmp4-betamp4nbprojectbuild-impl.xml:603:
The following error occurred while executing this line:
Q:Mp3 Appmp4-betamp4nbprojectbuild-impl.xml:284: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 8 seconds)
真正的问题是,这是从netbeans生成的代码。。。此外,如果您创建了一个新的Project->java->Destop应用程序,并且将其保留在那里而不添加任何内容,那么它总是会给我带来同样的问题。。。该怎么办????????????
netbeans版本:6.9.1jdk版本:7O.S:Windows 7 32位
您不应该使用Netbeans创建GUI,因为它会生成不可读的代码。Swing
-包是非常直接的,所以你应该使用它
对于错误:你有mp4AboutBox
-类吗?它里面有什么?
您可能缺少导入。在该文件中提供您的导入。
我遇到了一个类似的问题,我通过重新安装netbeans 6.9.1得到了解决方案。
这就是我从中得出的解决方案:
测试项目类别:
import org.jdesktop.application.Application;
import org.jdesktop.application.SingleFrameApplication;
public class TestProject extends SingleFrameApplication {
@Override protected void startup() {
show(new AppView(this));
}
@Override protected void configureWindow(java.awt.Window root) { }
public static TestProject getApplication() {
return Application.getInstance(TestProject.class);
}
public static void main(String[] args) {
launch(TestProject.class, args);
}
}
AppView JFrame:
import org.jdesktop.application.FrameView;
import org.jdesktop.application.SingleFrameApplication;
public class AppView extends FrameView {
public AppView(SingleFrameApplication app) {
super(app);
JFrame mainFrame = TestProject.getApplication().getMainFrame();
AboutBox newAboutBox = new AboutBox();
newAboutBox.setLocationRelativeTo(mainFrame);
TestProject.getApplication().show(newAboutBox);
}
}