求java swing 游戏菜单加上按钮触发事件 代码eclispe
packagegame;importjavax.swing.*;importjava.awt.*;publicclasssnakeMenu{publicstaticvoi...
package game; import javax.swing.*; import java.awt.*; public class snakeMenu { public static void main(String[] args){ JFrame app =new JFrame("菜单"); app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); app.setSize(250,300); Container c =app.getContentPane(); c.setLayout(null); //c.setLayout(new BoxLayout(c,BoxLayout.Y_AXIS)); JButton button =new JButton("玩家注册"); JButton button1=new JButton("开始游戏"); JButton button2=new JButton("游戏设置"); JButton button3=new JButton("帮助"); JButton button4=new JButton("分数榜"); JButton button5=new JButton("退出游戏"); c.add(button); c.add(button1); c.add(button2); c.add(button3); c.add(button4); c.add(button5); button.setBounds(60, 20, 120, 30); button1.setBounds(60, 60, 120, 30); button2.setBounds(60, 100, 120, 30); button3.setBounds(60, 140, 120, 30); button4.setBounds(60, 180, 120, 30); button5.setBounds(60, 220, 120, 30); app.setVisible(true); app.setLocation(400,200); } }
展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询