I have a root panel (2 rows, 1 column) which has panel P and a label L in it. P has a JComboBox B in it. Whenever I click on B, the resulting dropdown shows-up behind L. How do I fix this? I played around with all sorts of setComponentZOrder() but I could not fix this. What should I do?
Asked
Active
Viewed 1,879 times
5
-
I am using MigLayout("wrap 1") on the root panel – pathikrit Jul 19 '11 at 18:47
-
4I never see that (except `OverlayLayout`), which `LayoutManager` is used for ? or by mixing `ATW Components` with `Swing JComponents` – mKorbel Jul 19 '11 at 18:50
-
You were right I had mixed in a awt.Label instead of using swing.JLabel. Switching to latter, fixed my problem. Thank you. – pathikrit Jul 19 '11 at 18:55
-
@mKorbel: This happens even when combining `JFrame.getRootPane()` with Swing components as I've just experienced. Btw., I can see you're even more active than you used to be on "builder". – maaartinus Jan 21 '14 at 02:58
-
@maaartinus I can't believe ...., :-) – mKorbel Jan 21 '14 at 07:48
2 Answers
4
Don't mix heavyweight components (e.g. Label) with lightweight components (e.g. JLabel).
If you use Swing always use lightweight components starting with a J.

Marcel
- 3,749
- 6
- 29
- 35