0

I used this code previously in netbeans 6.9.1 but it does not seem to work in 7.1.1, it underlines .getApplication() with the hint "cannot find symbol".

How can I make this work again?

JFrame mainFrame = TestProject.getApplication().getMainFrame();
AboutBox newAboutBox = new  AboutBox();
newAboutBox.setLocationRelativeTo(mainFrame);
TestProject.getApplication().show(newAboutBox);

Here is a similar question, but the solution does not work.

Community
  • 1
  • 1
thewikus
  • 445
  • 1
  • 5
  • 16

2 Answers2

0

Have you checked the static method getApplication() in TestProject.java? What does it show?

CodeBlue
  • 340
  • 2
  • 4
  • 9
  • It doesn't show that method, in the TestProject class, but it didn't have it when I had netbeans 6.9.1 either, but it still worked, i assumed that it is a basic java method, but at this stage it lokks more like it was a netbeans class. – thewikus Mar 22 '12 at 10:22
0

I found the solution by re-installing netbeans 6.9.1. It appears that there is a built-in library that is not in 7.1.1. I also found that the template I used was the "Desktop Application" template.

This is the solution I came up with from that:

TestProject 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:

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);
   }
}
thewikus
  • 445
  • 1
  • 5
  • 16