Adding a JComponent on top (z order) of the component in border layout
-
02-07-2021 - |
Question
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?
Solution
You could use the Layered Panes Component.
OTHER TIPS
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 onJXLayer (Java6)
use
JViewport
(notComponent
notContainer
) in the case the is there some (required figure forSwing GUI
isJFrame
-JScrollPane
-JPanel
)
use
CardLayout
forJFrames CENTER
area(shot to the dark) call
(re)validate
andrepaint()
to nearestContainer
as last code line in current code block for switching betweensJPanels
views
EDIT
you can to use OverlayLayout too