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 JInternalFrame
to 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.
精彩评论