3

For example:

layeredPane.setLayout(new MigLayout());
layeredPane.add(component, "pos 50 50, width 100, height 100", 0);

The 0 in this case does affect the component's layering, but I can't seem to figure out exactly how. I would like to overlay components, but because there is the second layout constraint for the MigLayout, I can't combine layering and positioning as usual with a JLayeredPane. Thanks

rtheunissen
  • 7,347
  • 5
  • 34
  • 65

1 Answers1

2

JLayeredPane haven't got implemented LayoutManager then there you have to setBounds or setSize by default, first parameter in constructor is used for JComponents, second for Type of Layer,

mKorbel
  • 109,525
  • 20
  • 134
  • 319
  • Check edit. The code works and the third parameter does affect the overlaying of the components added to it - I would just like to know if anyone knows exactly *how* it affects it. – rtheunissen Jan 15 '12 at 05:37
  • @paranoid-android second params is for LayersType – mKorbel Jan 15 '12 at 08:37
  • How would arbitrary int values for LayersType affect component order (z-axis) in that case? – rtheunissen Jan 15 '12 at 08:57
  • @paranoid-android good catch, really I haven't any idea, maybe you mixing add(JComponent, int (order)) with add(JComponent, layertype), add component with method setLayer(Component c, int layer, int position) – mKorbel Jan 15 '12 at 09:09
  • That's a really good idea, wasn't aware of `setLayer(Component c, int layer, int position)`. Should read the api more.. Thanks, I'll try it. – rtheunissen Jan 15 '12 at 09:20
  • Hi all. I took a look at the "setLayer( ... , int position ) constructor. Unfortunately it did not solve my problem. In my case I have a nice frame design with everything looking great. Except I need a layered pane for my main display area. WHEN I add the first layer (deeper layer, background) things are "GO". Sadly when I add a second overlay, layer -- Things *crash* I accept that things that 'don't work' will break. I find it frustrating that using the layered pane is such a problem if I need to use the miglayout manager too. Why? – will Aug 08 '12 at 13:02
  • put JPanel to the layer, then add JComponents by using MigLayout to JPanel – mKorbel Aug 08 '12 at 13:06