/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package myframe;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
int count;
question (){
tip
= new JLabel("那么问题来了:你是不是狗??");
tip.setBounds(100,10,200,100);
sure.addActionListener(this);
sure.setBounds(100,100,60,35);
cancel.addActionListener(this);
cancel.setBounds(200,100,60,35);
this.add(tip);
this.add(sure);
this.add(cancel);
this.setLayout(null);
this.setLocation(500,200);
this.setSize(400,200);
this.setVisible(true);
this.
setDefaultCloseOperation(JDialog.
DO_NOTHING_ON_CLOSE);
}
public static void main
(String[] args
) {
question q = new question();
}
@Override
String s
= e.
getActionCommand();
if(s.equals("是")){
}else if(s.equals("否")){
count++;
if(count!=3||count!=10||count!=50||count!=51){
}
if(count==3){
JOptionPane.
showMessageDialog(this,
"你已经按了3次了!!就此打住吧!");
}else if(count ==10){
JOptionPane.
showMessageDialog(this,
"好了,好了,已经十次了,既然你这么有毅力,就按到50次吧!");
}else if (count ==50){
JOptionPane.
showMessageDialog(this,
"恭喜你已经到达了50次!我也可以承认你不是狗了!可是距离成功还差一点!");
}else if(count ==51){
JOptionPane.
showMessageDialog(this,
"好吧!你赢了!虽然你不是狗,但你能按到50次,只能说明你傻!!");
}
}
}
}