在学习了javaGUI图形化界面后,做了一个小型的打地鼠游戏,比较简单。对于自己知识的总结。由于没有学习线程,所以这个游戏是由两个定时器控制。后期有待改进。
涉及知识点:JFrame、JPanel、JLabel、JButton、JComboBox、ImageIcon(设置图片)、Timer
PlayMouse.java
package com.briup.day13;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.Timer;
public class PlayMouse implements ActionListener {
private JFrame frame; // 容器窗口
private JPanel north, center; // 两个panel容器,放置位置北边和中间
private JComboBox<String> box; // 放置难易程度,下拉框
private JLabel timeLabel; // 时间标签
private JLabel timeValueLabel; // 时间值
private JLabel gradeLabel; // 得分标签