如何在netbeans平台中创建内部框架? [英] how to create internal frame in netbeans platform?

查看:86
本文介绍了如何在netbeans平台中创建内部框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了NewProject类,它扩展了JInternalFrame.然后,创建名为"NEW"的New ... Action,在文件菜单中进行了本地化.我将代码NewProject p = new NewProject(); p.setVisible(true);放置到该操作的ActionPerformed方法中.

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?

我通过代码部分解决了这个问题:

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)

}

但GUI损坏.当我创建新的内部框架时,在我移动该内部框架时会出现黑色背景. 知道如何解决吗?

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?

推荐答案

JDesktopPane .文章 如何使用内部框架 概述了要点,您可能会喜欢以下简短的在这种情况下使用ActionJMenu的示例.

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.

尽管NetBean的GUI编辑器很吸引人,但您可能希望先使用Swing组件感到更舒服.

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

附录:您不能添加一个 顶级容器 (例如JFrame)到另一个容器(例如 JDesktopPane ,但是您可以添加任意数量的 JDesktopPane .尝试演示看看它是如何工作的

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.

附录:啊,您的意思是 NetBeans平台 .抱歉,我没有使用过.

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

这篇关于如何在netbeans平台中创建内部框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆