java swing jframe jpanel,如何在Java Swing中将JFrame放入现有的JPanel中?

博主有一个开源Java Swing应用,其中JPanel分左右区域,左区有文本链接,点击SLA Criteria链接会弹出JFrame窗口。博主想将弹出窗口内容显示在JPanel右区,思考使用JInternalFrame是否可行。最后决定用JTabbedPane在VTreePanel右区显示弹出窗口内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

I have an open-source java swing application like this:

vA1xL.jpg

http://i47.tinypic.com/dff4f7.jpg

You can see in the screenshot, there is a JPanel divided into two area, left and right area. The left area has many text links. When I click the SLA Criteria link, it will pop-up the SLA Criteria window. The pop-up window is JFrame object.

Now, I'm trying to put the pop-up window into right area of the JPanel, so that means no pop-up window anymore, i.e. when I click the SLA Criteria link, its contents will be displayed at the right area of the JPanel. The existing content of the right area of JPanel will not be used anymore. The concept is just same like in the java api documentation page: http://docs.oracle.com/javase/6/docs/api. You click the link in the left frame, you'll get the content displayed at the right frame.

The example illustration is like this:

(note: it's made and edited using image editor, this is not a real screenshot of working application)

So, I would like to know is there a way to put JFrame into JPanel?

I'm thinking of using JInternalFrame, is it possible? Or is there another way?

UPDATE:

Source code:

http://pastebin.com/tiqRbWP8 (VTreePanel.java, this is the panel with left & right area divisions)

http://pastebin.com/330z3yuT (CPanel.java, this is the superclass of VTreePanel and also subclass from JPanel)

http://pastebin.com/MkNsbtjh (AWindow.java, this is the pop-up window)

http://pastebin.com/2rsppQeE (CFrame.java, this is the superclass of AWindow and also subclass from JFrame)

解决方案

I had skimming the source codes, I saw that the AWindow.java has internal panel (APanel.java) to hold the window's content, and it also has a public method to return the content panel object (getAPanel()). With this, I can use it for fetching the window's contents into other container.

Finally, I decided to use JTabbedPane in the right area of VTreePanel for displaying the pop-up window's contents.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值