mport java.awt.Color;
import java.awt.Font;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
/**
*
* @author Administrator
*/
public class Test_ShuaRDao {
public static void main(String[] args) {
new HU_R_D("华容道游戏");
}
}
class Person extends JButton implements FocusListener{
int number;
Color c=Color.lightGray;
public Person(int number,String s){
//super(s);
this.setText(s);
this.setFont(new Font("宋体", 1,20));
this.setBackground(c);
this.number=number;
this.addFocusListener(this);
}
@Override
public void focusGained(FocusEvent e) {
this.setBackground(Color.red);
System.out.println("sdfs");
}
@Override
public void focusLost(FocusEvent e) {
this.setBackground(c);
}
}
class HU_R_D extends JFrame implements ActionListener,KeyListener,MouseListener{
Person person[] =new Person[10];
JButton up ,left,right,below;
JButton restart=new JButton("重新开始玩");
public HU_R_D (String s){
super(s);
init();
this.setBounds(20, 20, 500, 650);
this.setBackground(Color.white);
this.validate();
//this.pack();
this.setVisible(true);
this.addWindowListener(new WindowAdapter(){
@Override
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
}
public void init(){