管理多个框架应用程序
我正在编写一个应用程序,其中应用程序的用户在多个窗口或框架
(在java中)之间切换。
有没有其他方法可以在这些 frame
之间切换,而不是使 frame
对 false/true
可见?
I'm writing an application in which the user of the application switches between multiple windows or frames
(in java).
Is there any other way to switch between these frame
s instead of making a frame
visible to false/true
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它实际上需要是不同的框架(或 JFrame)还是只是不同的内容集?您需要单独的菜单栏、框架标题等吗?一般来说,应用程序可以有一个带有多个内容面板的单个框架,这些面板可以切换进和出(可能使用诸如 CardLayout 之类的东西。)当然有一些方法可以实现您想要的 - 您是说您想让不同的框架保持可见而只是将不同的一个带到前面?如果是这样,所有框架都有一个 toFront() 调用,它将把它弹出到显示顺序的前面,但您还需要处理焦点问题。
Does it actually need to be different Frames (or JFrames) or is it just different sets of content? Do you need separate MenuBars, Frame Titles, etc? Generally speaking, an Application can have a single frame with multiple panels of content that switch in and out (Possibly using something like a CardLayout.) There are certainly ways to do what you want - are you saying you want to keep the different Frames visible while just bringing a different one to the front? If so, all Frames have a toFront() call that will pop it to the front of the display order, but you'll need to deal with focus issues as well.
如果此时窗口不可见,
setVisible()
是正确的方法。如果窗口不可见,您可以使用
requestFocus()
和requestForcusInWindow()
。If window is not visible at the moment
setVisible()
is the right way.If window is invisible you can use
requestFocus()
andrequestForcusInWindow()
.