2

I have a JPanel which is a BorderLayout and I have set a new panel in the top and container (JDesktopPane) in center and another panel in bottom. Now I want to set panel (card layout) dynamically in center of container as I am showing hierarchy below

           top --> panel
panel(BorderLayout)center --> container(JDesktopPane) --> panel(CardLayout)
            bottom --> panel

Here card layout contain different panel as card. problem is that I'm unable to show each card in center of container.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Krishna Shrestha
  • 1,662
  • 14
  • 38

2 Answers2

3

how to show them center of container?

Put them in a panel with a GridBagLayout, add them as the only component with no constraint, and they will be centered. See this answer for an example.

Community
  • 1
  • 1
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
-1

- GroupLayout provides a hassle free way arranging the components as you want them too.

- GroupLayout was developed by NetBeans Group in 2005.

- You can download the Windows Builder Pro for free from Google, and use it.

Kumar Vivek Mitra
  • 33,294
  • 6
  • 48
  • 75