云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > 《Java语言课程设计》论文模板

《Java语言课程设计》论文模板

  • 62 次阅读
  • 3 次下载
  • 2025/5/7 0:19:10

本科课程设计论文

this.setTitle(\老夏版贪吃蛇小游戏\ this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setLayout(null); this.setResizable(false); int left = 10; optionPanel = new GameOptionPanel(); gamePanel = c.getGamePanel(); snake = c.getSnake(); ground = c.getGround(); food = c.getFood(); infoLabel = c.getGameInfoLabel() == null ? new JLabel() : c .getGameInfoLabel(); c.setGameInfoLabel(infoLabel); optionPanel.getButton_griddingColor().addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { Color griddingColor = JColorChooser.showDialog( MainFrame.this, \请选择网格的颜色\Color.LIGHT_GRAY); if (griddingColor != null) ground.setGriddingColor(griddingColor); } }); optionPanel.getButton_backgroundColor().addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { Color backgroundColor = JColorChooser .showDialog(MainFrame.this, \请选择背景的颜色\ new Color(0xcfcfcf)); if (backgroundColor != null) gamePanel.setBackgroundColor(backgroundColor); } }); optionPanel.getButton_foodColor().addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { Color foodColor = JColorChooser.showDialog( MainFrame.this, \请选择食物的颜色\Color.DARK_GRAY); if (foodColor != null)

37

本科课程设计论文

food.setColor(foodColor); } }); optionPanel.getButton_headColor().addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { Color headColor = JColorChooser .showDialog(MainFrame.this, \请选择蛇头的颜色\ new Color(0xFF4500)); if (headColor != null) snake.setHeadColor(headColor); } }); optionPanel.getButton_bodyColor().addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { Color bodyColor = JColorChooser.showDialog( MainFrame.this, \请选择蛇身体的颜色\Color.DARK_GRAY); if (bodyColor != null) snake.setBodyColor(bodyColor); } }); this.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent arg0) { controller.pauseGame(); if (optionPanel.getPauseButton().isEnabled()) optionPanel.getPauseButton().setText(\继续游戏\ } }); gamePanel.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent arg0) { // controller.continueGame(); } public void focusLost(FocusEvent arg0) { controller.pauseGame(); if (optionPanel.getPauseButton().isEnabled()) optionPanel.getPauseButton().setText(\继续游戏\ } });

38

本科课程设计论文

optionPanel.getRadioButton_map2().addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { controller.setMap(optionPanel.getRadioButton_map2() .isSelected() ? 2 : 1); } }); optionPanel.getNewGameButton().addActionListener(new ActionListener() { /** * 开始游戏的按钮 */ public void actionPerformed(ActionEvent e) {

// TODO Auto-generated method stub if (controller.isPlaying()) { return; }

controller.newGame(); } });

optionPanel.getStopGameButton().addActionListener(new ActionListener() { /** * 停止游戏的按钮 */ public void actionPerformed(ActionEvent e) { controller.stopGame(); } });

optionPanel.getPauseButton().setEnabled(false); optionPanel.getStopGameButton().setEnabled(false);

optionPanel.getPauseButton().addActionListener(new ActionListener() { /** * 暂停/继续游戏的按钮 */ public void actionPerformed(ActionEvent e) { if (controller.isPausingGame()) { controller.continueGame();

39

本科课程设计论文

} else { controller.pauseGame(); } if (controller.isPausingGame()) optionPanel.getPauseButton().setText(\继续游戏\ else optionPanel.getPauseButton().setText(\暂停游戏\ } });

optionPanel.getCheckBox_drawGridding().addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent arg0) { optionPanel.getButton_griddingColor().setVisible( optionPanel.getCheckBox_drawGridding() .isSelected()); ground.setDrawGridding(optionPanel .getCheckBox_drawGridding().isSelected()); } }); optionPanel.getButton_default().addActionListener(new ActionListener() { /** * 恢复默认设置的按钮 */ public void actionPerformed(ActionEvent e) {

gamePanel

.setBackgroundColor(GamePanel.DEFAULT_BACKGROUND_COLOR); optionPanel.getCheckBox_drawGridding().setSelected(false); ground.setGriddingColor(Ground.DEFAULT_GRIDDING_COLOR); snake.setHeadColor(Snake.DEFAULT_HEAD_COLOR); snake.setBodyColor(Snake.DEFAULT_BODY_COLOR); optionPanel.getRadioButton_map1().setSelected(true);

} });

infoLabel.setBounds(10, 0, infoLabel.getSize().width - 10, infoLabel .getSize().height);

gamePanel.setBounds(0, infoLabel.getSize().height, gamePanel.getSize().width, gamePanel.getSize().height); JPanel subPanel = new JPanel(); subPanel.setLayout(null);

40

搜索更多关于: 《Java语言课程设计》论文模板 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

本科课程设计论文 this.setTitle(\老夏版贪吃蛇小游戏\ this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setLayout(null); this.setResizable(false); int left = 10; optionPanel = new GameOptionPanel(); gamePanel = c.getGamePanel(); snake = c.getSnake(); ground = c.getGround(); food = c.getFood(); infoLabel = c.getGameInfoLabel() == null ? new JLabel() : c

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com