将JFrame放置在JFrame中 [英] Placing JFrames inside JFrames

查看:65
本文介绍了将JFrame放置在JFrame中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个包含许多JFrame的应用程序,其业余结果是我的程序多次出现在任务栏中,每个当前可见的JFrame一个.我知道JInternalFrame可能会解决我的问题,但是我已经制作了很多JFrame,很难切换!是否可以使我已经制成的JFrame出现在总体JFrame中?也许以某种方式将每个JFrame转移"到JInternalFrame中?

I'm working on an application that contains many JFrames, with the amateurish result that my program appears in the taskbar many times, one for each currently visible JFrame. I'm aware that JInternalFrame might solve my problem, but I've already made so many JFrames it's hard to switch! Is it possible to make my already-made JFrames appear within an overarching JFrame? Perhaps to somehow "transfer" each JFrame into a JInternalFrame?

我最终希望我的应用程序看起来像一个Android应用程序,具有一些可以像浏览器一样进行浏览的活动".

What I ultimately want my application to look like is something akin to an Android app, with several "activities" that you can navigate like a browser.

谢谢

推荐答案

是的,您总是可以从JFrame获取contentPane并将其放入JInternalFrame的contentPane中(通过预期的get和set方法),但是它很多尝试将好的代码添加到错误的设计中并不是一个好主意.您可能最好重构代码,并尝试针对JPanel而非JFrame进行编码.这样,您将可以灵活地将JPanel放置在所需的任何位置,无论它们是JInternalFrames,JDialogs,JTabbedPane组件还是通过CardLayout进行交换.

Yeah, you could always get the contentPane from a JFrame and put it into the contentPane of a JInternalFrame (via the expected get and set methods), but it's many times not a good idea to try to add good code into a bad design. You may be better off refactoring your code and try to code towards the JPanel and not the JFrame. That way you'll have the flexibilty of placing your JPanels wherever you wish, be they JInternalFrames, JDialogs, JTabbedPane components, or swapped via CardLayout.

这篇关于将JFrame放置在JFrame中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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