在 JFrame 中绘制 JPane
我在网上搜索了一下,发现了很多关于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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看来您自己创建了一个 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.
作为替代方案,创建您自己的 顶级容器 并添加您的设计器面板到其内容窗格。这是一个简单的示例。通过这种方式,您可以在探索 其他布局。
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.