Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
924 views
in Technique[技术] by (71.8m points)

java - how to create internal frame in netbeans platform?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...