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?

Était-ce utile?

La solution

You could use the Layered Panes Component.

Autres conseils

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top