开发者

Java JInternalFrame to JPanel

开发者 https://www.devze.com 2023-01-27 10:43 出处:网络
I have got a JFrame A und 2 JInternalFrame B und C. I want to开发者_如何学编程 show these two Frames B and C in a JPanel, rather than a JInternalFrame. Then i will put the jpanel to another Frame. So

I have got a JFrame A und 2 JInternalFrame B und C. I want to开发者_如何学编程 show these two Frames B and C in a JPanel, rather than a JInternalFrame. Then i will put the jpanel to another Frame. So B and C both will be shown as own JFrame. So my question is: How can i move JInternalFrame components to JPanel?

Thanks


It should be quite simple since both JInternalFrame and JPanel are subclasses of JComponent.

You could rename the extends JInternalFrameto extends JPanel at the beginning of your frame, change the constructor (since IIRC the ones of JInternalFrame require title, resizable and so on) and check if there are compilation errors (maybe yes, but small things) then you are done..


I want to show these two Frames B and C in a JPanel, rather than a JInternalFrame.

Why? Internal frames are designed to be used in a desktop pane. In order to get them to display properly in a JPanel you would basically need to customize the panel to work like a desktop pane. Why reinvent the wheel.

Then i will put the jpanel to another Frame. So B and C both will be shown as own JFrame.

So move the desktop pane to another frame. Why move them to a panel first.

Use the API the way it was designed to be used and you won't have problems.

0

精彩评论

暂无评论...
验证码 换一张
取 消