打地鼠游戏代码

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
jLabel10.setIcon(new javax.swing.ImageIcon(getClass().getResource(
jLabel10.addMouseListener(new java.awt.event.MouseAdapter(){public void mouseClicked(java.awt.event.MouseEvent evt){jLabel10MouseClicked(evt);}});
mouse[6].addMouseListener(new Catcher());
mouse[7] = jLabel8;
mouse[7].setBounds(279, 320, 80, 70);
mouse[7].addMouseListener(new Catcher());
mouse[8] = jLabel9;
for (int i = 0; i < mouse.length; i++){mouse[i].addMouseListener(new MouseCrab(cursor1, cursor2));}//GEN-BEGIN:
initComponents
// <editor-fold defaultstate="collapsed" desc="Generated Code">
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING).addGroup(
jPanel1Layout
.createSequentialGroup()
.addGroup(
jPanel1Layout
.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
Short.MAX_VALUE)
.addComponent(
jLabel5)).addGroup(
jPanel1Layout
.createSequentialGroup()
.addComponent(
jLabel1).addGap(39,
39,39).addComponent(
jLabel2))).addPreferredGap(
javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(
jPanel1Layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(
95,
Short.MAX_VALUE))
265,
265)
.addComponent(
jLabel10))
javax.swing.GroupLayout.Alignment.TRAILING,
.createSequentialGroup()
.addGap(513,
513,
513)
.addComponent(
jTextField2,
javax.swing.GroupLayout.DEFAULT_SIZE,
mouse[0] = jLabel1;
mouse[0].setBounds(135, 120, 80, 70);
mouse[0].addMouseListener(new Catcher());
mouse[1] = jLabel2;
mouse[1].setBounds(280, 120, 80, 70);
new Point(0, 0), "normal");
Cursor cursor2 = toolkit.createCustomCursor(
Image.hammer_down.getImage(), new Point(0, 0), "capture");
//鼠标监听器
addMouseListener(new MouseCrab(cursor1, cursor2));
.addGroup(
jPanel1Layout .createSequentialGroup()
.addGap(56,
56,
56)
.addGroup(
jPanel1Layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout
.createSequentialGroup()
.addGroup(
jPanel1Layout
.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING,
false)
.addGroup(
jPanel1Layout
/*
* MousGame.java** Created on __DATE__, __TIME__
*/
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.MouseEvent;
private void initComponents(){jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
mouse[8].setBounds(461, 320, 80, 70);
mouse[8].addMouseListener(new Catcher());
//使用绝对定位控制label在pane中的位置,与图片对应
jPanel1.setLayout(null);
//设置面板大小
jPanel1.setPreferredSize(new Dimension(Image.background.getIconWidth(),
49)
.addComponent(
jLabel8)
.addGap(68,
68,
68)
.addComponent(
jLab百度文库l9)))
.addGap(196,
196,
196))134,134).addComponent(
jLabel6)))).createSequentialGroup()
.addGap(265,
mouse[3].setBounds(128, 202, 80, 70);
mouse[3].addMouseListener(new Catcher());
mouse[4] = jLabel5;
mouse[4].setBounds(273, 202, 80, 70);
mouse[4].addMouseListener(new Catcher());
jLabel3)
.addGroup(
jPanel1Layout
.createSequentialGroup()
.addGap(134,.addGroup(
jPanel1Layout
.createSequentialGroup()
.addComponent(
jLabel7)
.addGap(49,
49,
mouse[1].addMouseListener(new Catcher());
mouse[2] = jLabel3;
mouse[2].setBounds(414, 120, 80, 70);
mouse[2].addMouseListener(new Catcher());
mouse[3] = jLabel4;
jTextField1.setForeground(new java.awt.Color(51, 255, 0));
jTextField2.setEditable(false);
jTextField2.setFont(new java.awt.Font("楷体", 1, 18));
jTextField2.setForeground(new java.awt.Color(153, 0, 153));
.createSequentialGroup()
.addComponent(
jLabel4).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE,
/** Creates new form MousGame */
public MousGame(){initComponents();
//设置窗体不能变大
setResizable(false);
//设置背景图片
JLabel background = new JLabel(Image.background);
import java.awt.event.MouseListener;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
/**** @author __USER__
*/
public class MousGame extends javax.swing.JFrame implements Runnable {private JLabel[] mouse = new JLabel[9];
jPanel1.setOpaque(false);
jPanel1.add(background, new Integer(Integer.MIN_VALUE));
background.setBounds(0, 0, Image.background.getIconWidth(),
Image.background.getIconHeight());
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(
jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout
.setHorizontalGroup(jPanel1Layout
Image.background.getIconHeight()));
//鼠标样式
Toolkit toolkit = Toolkit.getDefaultToolkit();
}Cursor cursor1 = toolkit.createCustomCursor(Image.hammer.getImage(),
mouse[5] = jLabel6;
mouse[5].setBounds(430, 202, 80, 70);
mouse[5].addMouseListener(new Catcher());
mouse[6] = jLabel7;
mouse[6].setBounds(91, 320, 80, 70);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);jTextField1.setEditable(false);
jTextField1.setFont(new java.awt.Font("黑体", 1, 18));
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jTextField2 = new javax.swing.JTextField();
jLabel10 = new javax.swing.JLabel();
相关文档
最新文档