问题
I'm trying to create an app with a JLayeredPane
that scales automatically with the size of the parent JFrame
(this is the easy part using BorderLayout
as layout manager on the frame's content pane). The hard part is the fact that I want the content of the JLayeredPane
to automatically resize with the JLayeredPane
(and thus the JFrame
too).
In fact the functionality I want to achieve is a lot like the dockable console in Netbeans, that just like comes "on top" of the editor when clicked, and when dismissed hides again and docks into the "console" word in the status bar. Obviously I also want resizing behavior to work correctly. What would be the best way to achieve this (if not with JLayeredPane
)?
回答1:
You'll need to use a ComponentListener added to the JLayeredPane and have its content responds to the void componentResized(ComponentEvent e)
method.
来源:https://stackoverflow.com/questions/12755083/automatic-content-resizing-of-jlayeredpane