Adding panel in center of container

我只是一个虾纸丫 提交于 2019-12-08 00:25:23

问题


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.


回答1:


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.




回答2:


- 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.



来源:https://stackoverflow.com/questions/12768592/adding-panel-in-center-of-container

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!