问题描述
importjava.awt.Color;importjavax.swing.*;publicclasszhuhanshu{publicstaticvoidmain(String[]args){JFramefra=newJFrame("虐待鼠标");fra.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);ciyijiBord=newciyiji();fra.getContentPane().add(Bord);fra.pack();fra.setVisible(true);}}importjava.awt.*;importjavax.swing.*;publicclassciyijiextendsJPanel{publicciyiji(){setLayout(newBorderLayout());setBackground(Color.red);JPanelb2=newJPanel();cierjitele=newcierji();//jianliziguanxib2.add(tele);add(b2,BorderLayout.CENTER);}}importjava.awt.*;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjavax.swing.*;publicclasscierjiextendsJPanel{privateJButtonb1;//新的按钮privateStringb="";privateintcount;longbegin=System.currentTimeMillis();//获取一个开始时间publiccierji(){b1=newJButton("求虐:");ButtonListenerlistener=newButtonListener();//jiantingb1.addActionListener(listener);add(b1);}privateclassButtonListenerimplementsActionListener{publicvoidactionPerformed(ActionEventarg0){count++;b1.setText("已被虐:"+count);longend=System.currentTimeMillis();//获取一个结束时间if(end>begin+10000)//停止{b1.setEnabled(false);}}}}