imimport java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
public class StartExam1 extends JFrame implements ItemListener,ActionListener{
private JLabel  prompt ,prompt1; //提示两个变量
private JTextPane title ; //题目文本
private JTextField answer; // 答案
private JRadioButton A , B ,C ,D ;
  private JButton finish,restart,front,rear;
  private JButton t[]; //按扭数组
  
  public StartExam1(){
   super("驾驶理论模拟考试");
   title = new JTextPane(); ;// 运用别的类 调用出题目
   //ReturnTimu rtimu = new ReturnTimu();  //NEW一个获得题目的类 
   //String str; //定义字符
   //str = rtimu.getTitle(5); //获得题目 
   //title.setText(str);  // 写入TEXT中
   prompt = new JLabel("选择答案:");
   prompt1 = new JLabel("您选的答案是:");
   answer = new JTextField(2);
   A = new JRadioButton("A");
   B = new JRadioButton("B");
   C = new JRadioButton("C");
   D = new JRadioButton("D");
   front = new JButton("上一题");
   rear = new JButton("下一题");
   ButtonGroup bg = new ButtonGroup();
   bg.add(A);
   bg.add(B);
   bg.add(C);
   bg.add(D);
   finish = new JButton("完成交卷");
   restart = new JButton("重新开始");
   JPanel south = new JPanel();
   south.add(prompt1);
   south.add(answer);
   south.add(finish);
   south.add(restart);
   this.getContentPane().add(south,BorderLayout.SOUTH);
   t[0] = new JButton("第1题");
    t[1] = new JButton("第2题");
    t[2] = new JButton("第3题");
    t[3] = new JButton("第4题");
    t[4] = new JButton("第5题");
    t[5] = new JButton("第6题");
    t[6]= new JButton("第7题");
    t[7]= new JButton("第8题");
    t[8] = new JButton("第9题");
    t[9] = new JButton("第10题");
    JPanel center = new JPanel();
    center.add(title);
    this.getContentPane().add(center,BorderLayout.CENTER);
   JPanel north = new JPanel();
   north.add(prompt);
   north.add(A);
   north.add(B);
   north.add(C);
   north.add(D);
   north.add(front);
   north.add(rear);
   this.getContentPane().add(north,BorderLayout.NORTH);
   JPanel east = new JPanel(new GridLayout(10,10));
    //依次添加10个按钮进画板
   east.add(t[0]);
   east.add(t[1]);
   east.add(t[2]);
   east.add(t[3]);
   east.add(t[4]);
   east.add(t[5]);
   east.add(t[6]);
   east.add(t[7]);
   east.add(t[8]);
   east.add(t[9]);
    this.getContentPane().add(east,BorderLayout.EAST);
    //为每个按钮添加监听对象
    A.addItemListener(this);
    B.addItemListener(this);
    C.addItemListener(this);
    D.addItemListener(this);
    t[0].addItemListener(this);
    t[1].addItemListener(this);
    t[2].addItemListener(this);
    t[3].addItemListener(this);
    t[4].addItemListener(this);
    t[5].addItemListener(this);
    t[6].addItemListener(this);
    t[7].addItemListener(this);
    t[8].addItemListener(this);
    t[9].addItemListener(this);
    finish.addItemListener(this);
    restart.addItemListener(this);
    front.addItemListener(this);
    rear.addItemListener(this);
  }
  public void actionPerformed(ActionEvent e) { //实现ItemListener接口的方法
   System.out.println("b");
  }
  public void itemStateChanged(ItemEvent e){ //实现itemSateChanged接口的方法
   System.out.println("i");
  }
  
  public static void main(String args[]) {
   StartExam1 start = new StartExam1();
   start.setSize(500,300);
   start.setResizable(true);
   start.setVisible(true);
  } 
}