1

我正在 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 App\mp4-beta\mp4\build\classes
Q:\Mp3 App\mp4-beta\mp4\src\mp4\Mp4View.java:223: cannot find symbol
symbol  : class mp4AboutBox
location: class mp4.Mp4View
        aboutBox = new mp4AboutBox(mainFrame);

1 error
Q:\Mp3 App\mp4-beta\mp4\nbproject\build-impl.xml:603: 
The following error occurred while executing this line:
Q:\Mp3 App\mp4-beta\mp4\nbproject\build-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.1 jdk 版本:7 操作系统:Windows 7 32 位

4

3 回答 3

1

您不应该使用 Netbeans 创建 GUI,因为它会生成不可读的代码。-PackageSwing非常简单,因此您应该使用它。

错误:你有一个mp4AboutBox-class,里面有什么?

于 2011-05-24T17:15:49.763 回答
0

您可能缺少导入。在该文件中提供您的导入。

于 2011-05-24T19:48:47.983 回答
0

我有一个类似的问题,我通过重新安装 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);
   }
}
于 2012-03-25T22:15:14.680 回答