使用 JInternalFrame 和一些按钮
我们可以使用 JInternalFame
主框架中有一个按钮?当然,该框架包含一个JDesktopPane
。该按钮应该打开JInternalFrame
如何?
Can we use a JInternalFame
with a button in the main frame? The frame contains a JDesktopPane
, of course. The button should open up the JInternalFrame
How?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道如何将
JButton
直接放在JDesktopPane
上,但您可以使用菜单项来创建和选择JInternalFrame
。在此示例中,每个菜单项都使用 < a href="https://docs.oracle.com/javase/tutorial/uiswing/misc/action.html" rel="nofollow noreferrer">Action
中定义>JInternalFrame 选择相应的框架。附录:正如 @camickr 所建议的,在技术上可以将
JButton
直接放在JDesktopPane
上,但在实践中可能很难使用。I don't know a way to put a
JButton
directly on aJDesktopPane
, but you can use menu items to create and select aJInternalFrame
. In this example, each menu item uses anAction
defined in theJInternalFrame
to select the corresponding frame.Addendum: as @camickr suggests, it is technically possible to put a
JButton
directly on aJDesktopPane
, but it might prove difficult to use in practice.我不太明白这个问题,所以我只是做一些观察。
a) JInternalFrme 就像一个框架,您可以向其中添加任何您想要的组件
b) 无论是添加到内部框架还是框架,JButton 的工作原理都是相同的
我建议您首先阅读 Swing 教程 了解工作示例。您可以从“如何使用内部框架”和“如何使用按钮”部分开始。
如果您仍然遇到问题,请发布您的 SSCCE 以显示您已尝试过的操作。
I don't really understand the question so I will just make some observations.
a) a JInternalFrme is like a frame in that you can add any component to it that you want
b) A JButton works the same whether it is added to an internal frame or a frame
I suggest you start by reading the Swing tutorial for working examples. You might start with the sections on "How to Use Internal Frames" and "How to Use Buttons".
If you still have problems then post your SSCCE that shows what you have tried.