[Java] 无聊的整蛊游戏 →→→→→进入此内容的聊天室

来自 , 2019-09-11, 写在 Java, 查看 126 次.
URL http://www.code666.cn/view/c60d060b
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6.  
  7. package myframe;
  8.  
  9. import java.awt.event.ActionEvent;
  10. import java.awt.event.ActionListener;
  11. import javax.swing.JButton;
  12. import javax.swing.JDialog;
  13. import javax.swing.JFrame;
  14. import javax.swing.JLabel;
  15. import javax.swing.JOptionPane;
  16.  
  17.  
  18. public class question  extends JFrame implements ActionListener{
  19.     JLabel tip;
  20.     JButton sure ,cancel ;
  21.     int count;
  22.     question (){
  23.         tip = new JLabel("那么问题来了:你是不是狗??");
  24.         tip.setBounds(100,10,200,100);
  25.         sure = new JButton("是");
  26.         sure.addActionListener(this);
  27.         sure.setBounds(100,100,60,35);
  28.         cancel = new JButton("否");
  29.         cancel.addActionListener(this);
  30.         cancel.setBounds(200,100,60,35);
  31.        
  32.         this.add(tip);
  33.         this.add(sure);
  34.         this.add(cancel);
  35.        
  36.         this.setLayout(null);
  37.         this.setLocation(500,200);
  38.         this.setSize(400,200);
  39.         this.setVisible(true);
  40.        
  41.         this.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
  42.     }
  43.     public static void main(String[] args) {
  44.         question q = new question();
  45.     }
  46.  
  47.     @Override
  48.     public void actionPerformed(ActionEvent e) {
  49.         String s = e.getActionCommand();
  50.        
  51.         if(s.equals("是")){
  52.             JOptionPane.showMessageDialog(this,"你终于能正视自己了!!");
  53.             System.exit(0);
  54.         }else if(s.equals("否")){
  55.            
  56.             count++;
  57.             if(count!=3||count!=10||count!=50||count!=51){
  58.             JOptionPane.showMessageDialog(this,"你应该认清现实!!");
  59.             }
  60.             if(count==3){
  61.                JOptionPane.showMessageDialog(this,"你已经按了3次了!!就此打住吧!");
  62.             }else if(count ==10){
  63.                  JOptionPane.showMessageDialog(this,"好了,好了,已经十次了,既然你这么有毅力,就按到50次吧!");
  64.             }else if (count ==50){
  65.                  JOptionPane.showMessageDialog(this,"恭喜你已经到达了50次!我也可以承认你不是狗了!可是距离成功还差一点!");
  66.             }else if(count ==51){
  67.                 JOptionPane.showMessageDialog(this,"好吧!你赢了!虽然你不是狗,但你能按到50次,只能说明你傻!!");
  68.                 System.exit(0);
  69.             }
  70.         }
  71.     }
  72. }
  73.  

回复 "无聊的整蛊游戏"

这儿你可以回复上面这条便签

captcha