clicklabel.java

来自「java写的模仿windows上的挖雷的游戏」· Java 代码 · 共 37 行

JAVA
37 行
字号

import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
public class ClickLabel extends MouseAdapter
{
  int i,j;
  MainFrame theFrame;
  ClickLabel(MainFrame theFrame,int i,int j)
  {
    this.i = i;
    this.j = j;
    this.theFrame = theFrame;
  }

  public void mousePressed(MouseEvent e)
  {
    if(e.getButton()==e.BUTTON1)
      theFrame.mineButton[i][j].setLeftFlag(true);
    else if(e.getButton()==e.BUTTON3)
      theFrame.mineButton[i][j].setRightFlag(true);
    if(theFrame.mineButton[i][j].getLeftFlag()&&theFrame.mineButton[i][j].getRightFlag())
      theFrame.twoButtonPressed(i,j);
  }
  public void mouseReleased(MouseEvent e)
  {
    if(theFrame.mineButton[i][j].getLeftFlag()&&theFrame.mineButton[i][j].getRightFlag())
    {
      theFrame.mineButton[i][j].setLeftFlag(false);
      theFrame.mineButton[i][j].setRightFlag(false);
      theFrame.twoButtonReleasedOnLabel(i,j);
      return;
    }
    
    
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?