开发者

Switch between different JPanels in one JFrame without CardLayout-buttons

I'm new at Java GUI and I'm trying to make a program that shows a login screen and once logged in, a menu. What I am looking for is a way to navigate through diff开发者_JS百科erent JPanels in just one JFrame. To navigate the user should use buttons located inside these panels.

I use Netbeans to do this. The furthest I got is to open one JPanel in a JFrame, I've been trying to close one and open another but it won't work because the current panel stays open.

The reason I do not want to use the CardLayout is because I do not wish to have to tabs visible. I don't think you can hide them...

I hope you guy's can help me out,

thanks in advance!!


CardLayout does exactly what you want and absolutely does not require you to use tabs. In fact, the java tutorial on card layout provides a demo that uses a combobox to change between different cards.


Sound like you want to implement a wizard or similar. Take a look at the linked article.


Simply remove the panel from the contentPane and add the new you want to show. This have to be done by code when the button is pressed and all it's ok to change to the next panel.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜