如何创建一个游戏菜单有三个界面的游戏菜单,第一个接口有两个选择退出,继续选择团队,继续或背部,第3的播放界面如何创建带有3个接口
package SimpleSoccer;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenuBar;
import javax.swing.JPanel;
/** * * @author Andyblem */ public class TopLevelDemo {
static JButton startButton = new JButton("START");
static JButton exitButton = new JButton("EXIT");
static JButton backButton = new JButton("MENU");
static JPanel panel = new JPanel(new FlowLayout());
static JFrame frame;
private static void createAndShowGUI(){
frame = new JFrame("Top Level Demo");
frame.setSize(400,400);
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JMenuBar cyanMenuBar = new JMenuBar();
cyanMenuBar.setOpaque(true);
cyanMenuBar.setBackground(Color.cyan);
cyanMenuBar.setPreferredSize(new Dimension(200,180));
JLabel yellowLabel = new JLabel();
yellowLabel.setOpaque(true);
yellowLabel.setBackground(Color.yellow);
yellowLabel.setPreferredSize(new Dimension(200,20));
frame.setJMenuBar(cyanMenuBar);
frame.getContentPane().add(panel);
panel.add(startButton);
panel.add(exitButton);
// frame.getContentPane().add(exitButton);
frame.pack();
frame.setVisible(true);
}
public static void main(String args[]){
createAndShowGUI();
}
}
格式问题,我觉得这个问题不清楚。你的代码目前做了什么以及你需要哪些特定的部分? – PakkuDon
我的代码在屏幕上显示两个按钮(退出按钮和继续按钮)。如果您选择退出按钮退出程序,如果选择继续,则继续在选择团队的同一窗口中的另一个面板。窗口,您可以选择返回第一个窗口或继续游戏 –