创建具有多个面板和一帧的GUI [英] Creating a GUI with multiple panels and one frame
问题描述
我想创建一个简单的GUI。我有一个充满各种JMenuItems菜单栏。每个菜单项应该链接到一个不同的窗口。目前,我想做到这一点的最好办法是建立一个单一的框架,并建立各种JPanels。我的ActionListeners将切换不同的面板的知名度,只有一个面板应在同一时间可见。这是去了解任务的最佳方法是什么?或者,是否有更好的解决方法。
I am trying to create a simple GUI. I have a menu bar that is filled with various JMenuItems. Each menu item should link to a different "window". Currently, I am thinking the best way to do this is to create a single frame, and create various JPanels. My ActionListeners will toggle visibility of the different panels, and only one panel should be visible at a time. Is this the best way to go about the task? Or is there a better workaround.
推荐答案
是的,最好的办法是使用的 CardLayout 其中有一个伟大的教程(请参阅链接),以及许多在线的例子,包括在这个论坛上,其中一些我写的,其中包括:
Yes, the best way is to use a CardLayout of which there's a great tutorial (please see the link), and many examples online including in this very forum, several of which I've written, including:
- Java CardLayout主菜单问题
- Change JPanel的大小使用CardLayout
- Java CardLayout的JPanel向上移动,当第二次的JPanel添加
- Java摇摆;如何切换面板的可见性?
- Clear JFrame的组成部分,并于同JFrame中添加新的成品的配件
- 贵多帧切换
- JLabel显示倒计时,JAVA
- Java CardLayout Main Menu Problem
- Change size of JPanel using CardLayout
- Java CardLayout JPanel moves up, when second JPanel added
- Java swing; How to toggle panel's visibility?
- Clear components of JFrame and add new componets on the same JFrame
- gui multiple frames switch
- JLabel displaying countdown, java
这篇关于创建具有多个面板和一帧的GUI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!