views:

423

answers:

1

I created class NewProject extends JInternalFrame. Then I create New...Action named "NEW", localised in File menu. I put code NewProject p = new NewProject(); p.setVisible(true); to the ActionPerformed method of the action.

But when I run the module and click "NEW" in file menu, nothing appears. Where can be problem?

EDIT: I partially solved it by code:

public void actionPerformed(ActionEvent e) {

    JInternalFrame f = new JInternalFrame();
    f.setSize(500, 500);
    f.setVisible(true);
    JDesktopPane p = new JDesktopPane();
    p.add(f);

   //WindowManager.getDefault().getMainWindow().setTitle("fFF");
   WindowManager.getDefault().getMainWindow().add(p)

}

but GUI is broken. When I create new internal frame, the black background appears as I move by that frame. Any idea how to solve it?

+1  A: 

The customary Container for JInternalFrame is JDesktopPane. The article How to Use Internal Frames outlines the essentials, and you may like this short example of using Action and JMenu in this context.

Although the NetBean's GUI editor is appealing, you may want to become more comfortable using Swing components first.

Addendum: You can't add one Top-Level Container like JFrame to another like JDesktopPane, but you can add any number of JInternalFrame instances to a JDesktopPane. Try the demo to see how it works.

Addendum: Ah, you mean NetBeans Platform. Sorry, I've not used it.

trashgod
But the problem is I do not know how to get main window's desktoppane or whatever where I can attach my JFrame. I am speaking about Netbeans Platform.
joseph
Sorry about the broken tutorial link. See above for more.
trashgod
I am not sure If you understand me (i am not english speaking). I know how to create internal frame when I create my own main window. But I do not know how to get my internal frame into pre-created main window of Netbeans Plaform
joseph
Quite right; I misunderstood entirely.
trashgod