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?

Was it helpful?

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

  1. 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)

  2. use CardLayout for JFrames CENTER area

  3. (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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top