1

I have created 5 very similar panels that are suppuosed to be visible in the same area of a frame on at a time, What I mean is that when the app stars one of them (JPanel0) is visible and the other four are created but invisible and when i hit Button1, JPanel1 sets to visible and JPanel0 goes invisible, same with all.

I manage to get close with the BorderLayout But I cant get all of them to be centered in what would be the center position. Can someone help me? Thank you very much!

mKorbel
  • 109,525
  • 20
  • 134
  • 319

2 Answers2

5

Could CardLayout be what you may be looking for?

The Java Tutorials has an article on How to Use CardLayout, which includes an example which switches between a couple of JPanels which get swapped by using CardLayout.

coobird
  • 159,216
  • 35
  • 211
  • 226
0

Another option would be to use OverlayLayout.

Eugene Ryzhikov
  • 17,131
  • 3
  • 38
  • 60