nipponsahore -1 Newbie Poster

Thank You .. EveryBody .. for Your Support .. Finally Got my Project Working again ..

Now.. Im facing Only 1 Problem ..
The JRadioButtons .. Remain selected even when I get to the next Question ..
the Previous selection .. remains .. Selected..
any help how i can .. Correct this ..

here is the code

package Prj;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import javax.swing.JFrame;
import javax.swing.Timer;
import java.awt.*;
import java.awt.Event.*;

public class TestPage extends JFrame {
        Timer timer;
	
        JButton submit ,skip ;
 static JLabel timerLabel , ques, correctAnsLabel , NoOfCorrect ;
         JRadioButton opt1 , opt2 , opt3 , opt4 ;
         ButtonGroup bgp;
         static int  count = 20 , quesNo , correctAns , noOfCorrectAns ;





public TestPage(){
    quesNo = 0 ;
    noOfCorrectAns = 0 ;
    submit = new JButton("Submit");
    skip = new JButton("Skip");
    ques = new JLabel("Ques");
    NoOfCorrect = new JLabel("No Of Correct Answers : ");
    opt1 = new JRadioButton("opt1");
    opt2 = new JRadioButton("opt2");
    opt3 = new JRadioButton("opt3");
    opt4 = new JRadioButton("opt4");
    correctAnsLabel = new JLabel(Integer.toString(noOfCorrectAns));
    bgp = new ButtonGroup();
    bgp.add(opt1);
    bgp.add(opt2);
    bgp.add(opt3);
    bgp.add(opt4);




    
    
    
    //setVisible(true);
    setResizable(false);
    
    setLayout(null);
    
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        timer  = new Timer(1000,new ActionListener() {
      public void actionPerformed(ActionEvent actionEvent) {
        
          if(count==0){
               timer.stop();
                    nxtQues();
                    count = 20 ;
                    timer.restart();

          }
          else
		count--;
		timerLabel.setText(Integer.toString(count));
      }
    });
        timer.start();

	timerLabel = new JLabel(Integer.toString(count));
        timerLabel.setForeground(Color.red);
        timerLabel.setFont(new Font("Times New Roman",Font.BOLD,25));

        timerLabel.setBounds(450,25,50,25);

        skip.setBounds(250,420,100,30);
        submit.setBounds(350,420,100,30);
        correctAnsLabel.setBounds(200,420,100,30);
        NoOfCorrect.setBounds(50,420, 150,30);


        questionSelect();

        submit.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {

                Boolean a=checkAns();
                if(a){
                    nxtQues();
               correctAnsLabel.setText(Integer.toString(++noOfCorrectAns));}
                else
                    nxtQues();
                




            }
        });


        opt1.setBounds(330,180,100,30);
        opt2.setBounds(330,210,100,30);
        opt3.setBounds(330,240,100,30);
        opt4.setBounds(330,270,100,30);
        ques.setBounds(50,100,400,30);


        add(timerLabel);
	add(submit);
        add(skip);
        add(opt4);
        add(opt3);
        add(opt2);
        add(opt1);
        add(ques);
        add(correctAnsLabel);
        add(NoOfCorrect);


        pack();
        setSize(500,500);
        setVisible(true);
        
}

void nxtQues(){
    ++quesNo;
    questionSelect();
    count = 20 ;
    timer.restart();
   
    
    
}
boolean checkAns(){
    boolean a = false ;
    switch(correctAns)
    {
        case 1:
            if ( opt1.isSelected() )
                a = true ;
            break;
        case 2:
            if ( opt2.isSelected() )
                a = true ;
            break;
        case 3:
            if ( opt3.isSelected() )
                a = true ;
            break;
        case 4:
            if ( opt4.isSelected() )
                a = true ;
            break;
        default:
            System.out.println("Error");



    }
    
    return a ;


}

void questionSelect(){
    FileHandling.readFromQFile();

    opt1.setSelected(false);
    opt2.setSelected(false);
    opt3.setSelected(false);
    opt4.setSelected(false);
    ques.setText(FileHandling.y[quesNo][0]);
    opt1.setText(FileHandling.y[quesNo][1]);
    opt2.setText(FileHandling.y[quesNo][2]);
    opt3.setText(FileHandling.y[quesNo][3]);
    opt4.setText(FileHandling.y[quesNo][4]);

    correctAns = Integer.parseInt(FileHandling.y[quesNo][5]);
}


  public static void main(String args[]) {

 new TestPage();
 
  }
}