如何在Java Swing中将JFrame放入现有的JPanel中? [英] How to put JFrame into existing JPanel in Java Swing?

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

问题描述

我有一个像这样的开源Java swing应用程序: http://i47.tinypic.com/dff4f7.jpg

I have an open-source java swing application like this: http://i47.tinypic.com/dff4f7.jpg

您可以在屏幕截图中看到一个JPanel,分为两个区域,左侧和右侧区域.左侧区域有许多文本链接.当我单击 SLA条件链接时,它将弹出 SLA条件窗口.弹出窗口是JFrame对象.

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.

现在,我正在尝试将弹出窗口放入JPanel的正确区域,因此这意味着不再有弹出窗口,即当我单击 SLA Criteria 链接时,内容将显示在JPanel的右侧区域. JPanel正确区域的现有内容将不再使用.该概念与java api文档页面中的概念相同: http://docs.oracle .com/javase/6/docs/api .单击左侧框架中的链接,您将在右侧框架中显示内容.

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.

示例插图如下:

(注意:它是使用图片编辑器制作和编辑的,这不是正在运行的应用程序的真实屏幕截图)

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

http://i48.tinypic.com/5vrxaa.jpg

所以,我想知道是否可以将JFrame放入JPanel?

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

我正在考虑使用JInternalFrame,这可能吗?还是有另一种方法?

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

更新:
源代码:
http://pastebin.com/tiqRbWP8 (VTreePanel.java,这是具有左右区域的面板部门)
http://pastebin.com/330z3yuT (CPanel.java,这是VTreePanel的超类,也是VTreePanel的子类JPanel)
http://pastebin.com/MkNsbtjh (AWindow.java,这是弹出窗口)
http://pastebin.com/2rsppQeE (CFrame.java,这是AWindow的超类,也是AWindow的子类JFrame)

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)

推荐答案

我浏览了源代码,我看到AWindow.java具有内部面板(APanel.java)来保存窗口的内容,并且还具有一个返回内容面板对象(getAPanel())的public方法.这样,我就可以将其用于将窗口的内容提取到其他容器中.

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.

最后,我决定在VTreePanel的右侧区域中使用JTabbedPane来显示弹出窗口的内容.

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

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

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