在 JFrame 中绘制 JPane

发布于 2024-12-27 15:17:21 字数 211 浏览 2 评论 0原文

我在网上搜索了一下,发现了很多关于Java绘图的信息。但是,当我在 Netbeans 中添加新的 JFrame 类时,我无法在 JFrame 中添加自己的 JPane。希望有人可以帮助我解决这个问题。

当我在类中创建一个新的 JFrame 时,可以绘制 JPane,但我想使用 Netbeans 中的设计视图。当我创建一个新的 JFrame 时这是不可能的。

我期待收到答复。

I have search on internet and found a lot of information about drawing in Java. But when I add new JFrame class in Netbeans then I cannot add a own JPane in the JFrame. Hopefully somebody can help me with this issue/question.

Drawing the JPane is possible when I make a new JFrame in a class, but I would like to use the design view in Netbeans. That is not possible when I make a new JFrame.

I look forward to receiving an answer.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梨涡 2025-01-03 15:17:21

看来您自己创建了一个 JFrame 实例,然后尝试使用 NetBeans swing 构建器向其中添加 JPane(l)。这行不通。尝试使用 swing 构建器创建一个新的 swing 类,并让 netbeans 制作 Jframe。
另外,请确保为 JFrame 设置正确的布局。

另外,就像 BenCole 所说,我认为你指的是 JPanel,而不是 JPane。

It looks like you made a JFrame instance yourself, and then tried to add a JPane(l) to it using NetBeans swing builder. This wont work. Try creating a new swing class using the swing builder and let netbeans make the Jframe.
Also, make sure you set a correct layout for your JFrame.

Also, like BenCole said, I think you mean a JPanel, not a JPane.

尐偏执 2025-01-03 15:17:21

作为替代方案,创建您自己的 顶级容器 并添加您的设计器面板到其内容窗格。这是一个简单的示例。通过这种方式,您可以在探索 其他布局

As an alternative, create your own top level container and add your designer panel to its content pane. Here's a simple example. In this way you can limit the use of the designer to a single panel, while you explore other layouts.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文