[英]java - how to replace a jPanel based on user clicks
i have a jPanel containing 3 menus--lets call it MenuPanel i place it on the top of my jFrame (border_layout top). 我有一个包含3个菜单的jPanel,可以将其命名为MenuPanel,将其放在我的jFrame的顶部(border_layout顶部)。 i have also 3 jPanels (PanelOne, PanelTwo, PanelThree) and i want it to be showed on the bottom of the jFrame (border_layout bottom) based on the menu that the user choose
我也有3个jPanels(PanelOne,PanelTwo,PanelThree),我希望根据用户选择的菜单将其显示在jFrame的底部(border_layout底部)
Simple solution: use a CardLayout to help you swap JPanels. 简单的解决方案:使用CardLayout帮助您交换JPanels。
show(cardHolderPanel, APPROPRIATE_STRING_CONSTANT)
on your CardLayout. show(cardHolderPanel, APPROPRIATE_STRING_CONSTANT)
来交换卡片。 Tutorial: http://docs.oracle.com/javase/tutorial/uiswing/layout/card.html 教程: http : //docs.oracle.com/javase/tutorial/uiswing/layout/card.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.