打地鼠实训报告
实训题“打地鼠”游戏程序设计实训内容打地鼠的界面设计(含截图、代码)package com.iotek.mouse;import java.awt.Color;import java.awt.Font;import java.awt.Point;import java.awt.Toolkit;import java.awt.event.MouseEvent;import java.awt.event.MouseListener;import javax.swing.ImageIcon;import javax.swing.JFrame;import javax.swing.JLabel; public class PlayMouse extends JFrame implements Runnable{private int num = 0;private JLabel back;private JLabel [] mouses;private ImageIcon imgMouse;private JLabel jtf;public PlayMouse(){this.setResizable(false);//不能修改大小。this.getContentPane().setLayout(null);this.setTitle("打地鼠游戏");this.setBounds(400,200,1000, 600);back= new JLabel();ImageIcon icon = new ImageIcon(this.getClass().getResource("1.jpg"));back.setIcon(icon);back.setBounds(0, -10,1000,600);this.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(Toolkit.getDefaultToolkit().getImage("src/com/iotek/mouse/4.png"),new Point(),"self"));imgMouse = new ImageIcon(this.getClass().getResource("3.jpg"));mouses = new JLabel[6];for(int i=0;i<6;i++){mouses[i] = new JLabel();mouses[i].setSize(imgMouse.getIconWidth(), imgMouse.getIconHeight());//mouses[i].setIcon(imgMouse);mouses[i].addMouseListener(new MouseListener() {@Overridepublic void mouseReleased(MouseEvent e) {// TODO 自动生成的方法存根}@Overridepublic void mousePressed(MouseEvent e) {// TODO 自动生成的方法存根}@Overridepublic void mouseExited(MouseEvent e) {// TODO 自动生成的方法存根}@Overridepublic void mouseEntered(MouseEvent e) {// TODO 自动生成的方法存根}@Overridepublic void mouseClicked(MouseEvent e) {//加分功能Object object = e.getSource();if(object instanceof JLabel){JLabel label =(JLabel) object;if(label.getIcon()!=null){num++;jtf.setText("你的得分是: "+num+"分");}label.setIcon(null);}}});this.getContentPane().add(mouses[i]);}jtf = new JLabel();jtf.setBounds(350,250,200,70);jtf.setFont(new Font("",20,22));jtf.setForeground(Color.black);jtf.setText("你的得分是: 分");mouses[0].setLocation(100, 5);mouses[1].setLocation(400, 5);mouses[2].setLocation(700, 5);mouses[3].setLocation(100, 300);mouses[4].setL