Red de conocimiento informático - Aprendizaje de código fuente - El software de loterías y sorteos debe estar escrito en Java

El software de loterías y sorteos debe estar escrito en Java

importar java.awt.event.WindowAdapter;

importar java.awt.event.WindowEvent;

importar java.util.JTextField;

la clase pública RandomTest se extiende JFrame implementa Runnable {

JTextField tf = new JTextField();

public RandomTest() {

this.add(tf);

this.setSize(300,200);

this.setVisible(true);

this.addWindowListener(new WindowAdapter() {

public void windowClosing( WindowEvent e) {

// System.exit(0);

dispose();

}

});

}

public void run() {

String[] lista = { "aaa", "123", "ZhangSan", "LiSi" };

int time = 100; // El resultado se obtendrá después de 3 segundos

Random rd = new Random() // Clase de generación de números aleatorios

int i = 0;

while (tiempo > 0) {

prueba {

i = rd.nextInt(list.length);

tf.setText( lista[i]);

Thread.sleep(10);

tiempo --;

} captura (InterruptedException e ) {

// TODO Bloque de captura generado automáticamente

e.printStackTrace();

}

}

tf.setText("Ganador:" + lista[i]);

}

public static void main(String[] args) {

nuevo hilo(nuevo RandomTest()).start();

}

}