5

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?

Cœur
  • 37,241
  • 25
  • 195
  • 267
pathikrit
  • 32,469
  • 37
  • 142
  • 221
  • I am using MigLayout("wrap 1") on the root panel – pathikrit Jul 19 '11 at 18:47
  • 4
    I 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 Answers2

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
1

use combobox.setOpaque(true)

I found this here.

enrico.bacis
  • 30,497
  • 10
  • 86
  • 115
mamta
  • 11
  • 1