0

After adding a JPanel to a JLayeredPane using

layeredPane.add(panel);

After adding this if we change the panel does the panel in the JLayeredPane also change?

mKorbel
  • 109,525
  • 20
  • 134
  • 319
saviok
  • 497
  • 1
  • 6
  • 14

2 Answers2

2

Yes. Objects are passed by reference in Java, so any changes you make will effect it.

You may have to repaint the panel after making changes, in order to get it to show up correctly.

Dsynomic
  • 102
  • 7
2

After adding this if we change the panel does the panel in the JLayeredPane also change?

Yes is possible, but visible only by calling

layeredPane.add(panel);
layeredPane.revalidate();
layeredPane.repaint();
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
mKorbel
  • 109,525
  • 20
  • 134
  • 319
  • Why do you use code formatting for quotes that should be prefixed with `>`? Also `reapaint()` - is that home improvement by the Grim Reaper? ;) – Andrew Thompson Apr 18 '12 at 04:32