tags:

views:

241

answers:

1

Sorry if this question will sound too chaotic, feel free to edit it.

I have an application made entirely in netbeans, which uses SingleFrameApplication and auto-generated the GUI code, named "MyApp", and FrameView, named "MyView". Now, the MyApp somehow has the main() function, but the MyView has all the graphic elements..

I don't entirely understand how that happens, so used it as black box (it somehow created the window, I didn't have to care why). But now, I need the window to be only a window, opened by another JFrame. I don't know, how to accomplish that.

MyApp, which is extending SingleFrameApplication, have these methods:

public class MyApp extends SingleFrameApplication {

    @Override protected void startup() {
        show(new MyView(this));
    }

    @Override protected void configureWindow(java.awt.Window root) {
    }

    public static MyApp getApplication() {
        return Application.getInstance(MyApp.class);
    }

    public static void main(String[] args) {
       launch(MyApp.class, args);

    }
}

MyView has these methods:

public class MyView extends FrameView {

    public MyView(SingleFrameApplication app) {
        super(app);
        initComponents();
    }
    private void initComponents() {
        //all the GUI stuff is somehow defined here
    }
}

Now, I have no clue how the two classes work, I just want this window, defined in MyView, to appear after another window, "ordinary" JFrame. How can I call this MyApp/MyView?

+1  A: 

But now, I need the window to be only a window, opened by another JFrame. I don't know, how to accomplish that.

1.) It's not just a window - it's a Swing Framework Application (Ah, the perils of GUI builders...); and -

2.) You haven't specified how you want it "opened by another JFrame";

but something like this should work if you're launching it via a JButton -

JButton launchMyApp = new JButton("launch");
launchMyApp.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent evt) {
        String[] args = {};
        Application.launch(MyApp.class, args);
    }
});
Nate
thanks... I don't really understand the distinction between application, window, frame, frameview and whatnot. And I don't like GUI builders in frameworks I understand - however, awt/Java is not one of those.
Karel Bílek
Right - I was mentioning the "perils of GUI builders" part in regards to Netbeans.
Nate