import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import java.lang.*;
public class Dazi extends KeyAdapter
{
static int j=(int)(Math.random()*1000)%26;;
static JFrame f=new JFrame("Heart欢迎您进入打字练习板块:");
static String str[]={"A","B","C","D","E","F","G","H","I","G","K","L","M",
              "N","O","P","Q","R","S","T","U","V","W","X","Y","Z"
};
static JButton b[]=new JButton[str.length];
public Dazi()
{

f.setSize(600,600);
f.setLocation(50,50);
f.getContentPane().setLayout(new GridLayout(6,6));
loop();
}
public void loop()
{
for(int i=0;i<26;i++)
{
b[i]=new JButton(str[i]);
f.getContentPane().add(b[i]);
if(i!=j)
{
b[i].setVisible(false);
}
}
b[j].addKeyListener(this);
}
public void keyPressed(KeyEvent e)
{

if(e.getKeyCode()==j+65)
{
b[j].setVisible(false);
//System.out.println("Right!");
j=(int)(Math.random()*1000)%26;
loop();
}
//else
//System.out.println("Error!");
}
public static void main(String [] args)
{
Dazi d=new Dazi();

f.setVisible(true);
}
}