简体   繁体   English

java 中 aboutBox() 的问题

[英]Problem on aboutBox() in java

I'm developing a javadesktop application in Netbeans 6.9 and everything is perfect but...it gives me an error on this:我正在 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")

and this is the error:这是错误:

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)

the real problem is that this is the code generated from netbeans...also if you create a new Project->java->Destop Application and you leave it there without adding nothing,it gives always me the same problem... what to do????????????真正的问题是,这是从 netbeans...做????????????

netbeans version: 6.9.1 jdk version: 7 OS: Windows 7 32 bit netbeans 版本:6.9.1 jdk 版本:7 操作系统:Windows 7 32位

You shouldn't create your GUI using Netbeans because it generates unreadable code.您不应该使用 Netbeans 创建您的 GUI,因为它会生成不可读的代码。 The Swing -Package is pretty straight forward, so you should use it. Swing包装非常简单,因此您应该使用它。

To the Error: Do you have a mp4AboutBox -class and what is in it?错误:你有一个mp4AboutBox -class,里面有什么?

You might be missing an import.您可能缺少导入。 Provide your imports in that file.在该文件中提供您的导入。

I had a similar question that I got the solution to by re-installing netbeans 6.9.1.我有一个类似的问题,我通过重新安装 netbeans 6.9.1 得到了解决方案。

This is the solution I came up with from that:这是我从中提出的解决方案:

TestProject class:测试项目 class:

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: 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);
   }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM