importjava.lang.Runtime;importjava.awt.*;importjava.awt.event.*;importjava.io.*;publicclassGamesextendsFrameimplementsWindowAdapter,ActionListener,Runnable,TextListener{&...
import java.lang.Runtime;import java.awt.*;import java.awt.event.*;import java.io.*;public class Games extends Frame implements WindowAdapter,ActionListener,Runnable,TextListener{ static int times=100000; static Runtime r=Runtime.getRuntime(); static Games frm=new Games("游戏防沉迷-----戏子制作"); static TextField time=new TextField(); static Label lab=new Label("防沉迷时间:"); static Button btn=new Button("确定"); static Button btn1=new Button("取消"); static re=new Thread(this); public static void main(String args[]) { btn.addActionListener(frm); btn1.addActionListener(frm); frm.Layout(FlowLayout.CENTER); time.addTextListener(frm); frm.setBounds(250,250,400,300); frm.add(lab); frm.add(btn); frm.add(btn1); frm.add(time); lab.setBounds(40,40,80,40); // lab.setText("正谦樱桃小丸子字"); lab.setForeground(Color.red); time.setBounds(140,40,90,40); btn.setBounds(145,90,40,20); btn1.setBounds(195,90,40,20); // frm.run(); re.start(); } public void textValueChanged(TextEvent e) { times=Integer.parseInt(time.getText()); } public Games(String str) { super(str);} public void run() { sleep((int)times*1000);r.exec("shutdown -l"); } public void windowClosing(WindowEvent e) { frm.dispose(); System.exit(0); }}
展开