Reputation: 13386
Border layout has been really popular as it stretches it's contents to fit the parent component. And so I have some JComponent that is laid out with BorderLayout.CENTER
, and I need to show another JComponent a top of it. As some sort of properties window or something. Is there any common way to do it or should I rebuild the whole app?
Upvotes: 1
Views: 1341
Reputation: 109813
I have some JComponent that is laid out with BorderLayout.CENTER, and I need to show another JComponent a top of it
there are two (three ways)
use GlassPane
use JLayer (Java7)
, based on JXLayer (Java6)
use JViewport
(not Component
not Container
) in the case the is there some (required figure for Swing GUI
is JFrame
- JScrollPane
- JPanel
)
use CardLayout
for JFrames CENTER
area
(shot to the dark) call (re)validate
and repaint()
to nearest Container
as last code line in current code block for switching betweens JPanels
views
EDIT
you can to use OverlayLayout too
Upvotes: 4