www.pudn.com > newminesrc.zip > ClickButton.java, change:2002-07-10,size:1882b


 
import javax.swing.*; 
import javax.swing.event.*; 
import java.awt.event.*; 
public class ClickButton extends MouseAdapter 
{ 
  int i,j; 
  MainFrame theFrame; 
  ClickButton(MainFrame theFrame,int i,int j) 
  { 
    this.i = i; 
    this.j = j; 
    this.theFrame = theFrame; 
  } 
  /* 
  public void mouseClicked(MouseEvent e) 
  { 
    int inputbutton = e.getModifiers(); 
    switch(inputbutton) 
    { 
      case InputEvent.BUTTON1_MASK: 
        theFrame.clickButton(i,j); 
        theFrame.repaint(); 
        break; 
      case InputEvent.BUTTON3_MASK: 
        theFrame.clickRightRutton(i,j); 
        theFrame.repaint(); 
        break; 
    } 
     
  }*/ 
  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.twoButtonReleased(i,j); 
      return; 
    } 
    if((e.getButton()==e.BUTTON1)&&(theFrame.mineButton[i][j].getLeftFlag())&&(!theFrame.mineButton[i][j].getRightFlag())) 
    { 
      theFrame.mineButton[i][j].setLeftFlag(false); 
      theFrame.clickButton(i,j); 
      theFrame.repaint(); 
    } 
     
    else if((e.getButton()==e.BUTTON3)&&(!theFrame.mineButton[i][j].getLeftFlag())&&(theFrame.mineButton[i][j].getRightFlag())) 
    { 
      theFrame.mineButton[i][j].setRightFlag(false); 
      theFrame.clickRightButton(i,j); 
      theFrame.repaint(); 
    } 
     
  } 
}