That is the game frame:
[code]// File:GameFrame.java
// Purpose:The window that appears when the player chooses to play the game
//This window shows the questions and answers and the amount being played for
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.Vector;
import java.io.*;
public class GameFrame extends JFrame implements ActionListener {
private MainFrame frmMain;
private Vector questionVector;
private JTextField jtfquestions;
private JButton btnCancel, btnPrevious, btnNext, btnSelect,btnStart;
private JRadioButton jrba, jrbb, jrbc, jrbd;
private ButtonGroup btg = new ButtonGroup();
private JList score;
private final String money []= {"15. 1000000","14. 500000","13. 250000","12. 125000","11. 64000","10. 32000","9. 16000","8. 8000","7. 4000","6. 2000","5. 1000","4. 500","3. 300","2. 200","1. 100"} ;
public GameFrame(MainFrame mf)
{
frmMain = mf;// Get a handle on caller
score=new JList (money);
score.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JPanel p1=new JPanel();
ImageIcon logo=new ImageIcon ("millionaire.jpg");
p1.add(new JLabel(logo));
JPanel p2=new JPanel();
p2.add(score);
JPanel p5=new JPanel();
p5.setLayout(new GridLayout(2,3,4,4));
p5.add(jrba = new JRadioButton("A", false));
p5.add(jrbb = new JRadioButton("B", false));
p5.add(jrbc = new JRadioButton("C", false));
p5.add(jrbd = new JRadioButton("D", false));
btg.add(jrba);
btg.add(jrbb);
btg.add(jrbc);
btg.add(jrbd);
JPanel p3=new JPanel();
p3.setLayout(new FlowLayout(FlowLayout.LEFT,5,5));
p3.add(jtfquestions=new JTextField(50));
p3.add(p5);
JPanel p4=new JPanel();
p4.setLayout(new FlowLayout(FlowLayout.CENTER,5,5));
p4.add(btnCancel=new JButton("Cancel"));
p4.add(btnPrevious=new JButton("Previous"));
p4.add(btnNext=new JButton("Next"));
p4.add(btnSelect=new JButton("Select"));
p4.add(btnStart=new JButton("START"));
getContentPane().setLayout(new BorderLayout(5,5));
getContentPane().add(p1, BorderLayout.NORTH);
getContentPane().add(p2, BorderLayout.EAST);
getContentPane().add(p3, BorderLayout.CENTER);
getContentPane().add(p4, BorderLayout.SOUTH);
Container cn = this.getContentPane();
btnCancel.addActionListener(this);
btnPrevious.addActionListener(this);
btnStart.addActionListener(this);
btnNext.addActionListener(this);
jrba.addActionListener(this);
jrbb.addActionListener(this);
jrbc.addActionListener(this);
jrbd.addActionListener(this);
try
{
readFile("questions.dat");
}
catch (Exception e)
{
System.out.println(e);
}
}
public void actionPerformed(ActionEvent e)
{
}
public void readFile(String fileName) throws IOException
{
BufferedReader bReader;
String question;
questionVector = new Vector();
File inFile = new File(fileName);
if (!inFile.exists())
{
System.out.println("File does not exist");
//System.exit(0);
}
bReader = new BufferedReader(new FileReader(inFile));
question = bReader.readLine();
while (question != null)
{
String a1, a2, a3, a4, correct;
int iCorrect;
a1 = bReader.readLine();
a2 = bReader.readLine();
a3 = bReader.readLine();
a4 = bReader.readLine();
correct = bReader.readLine();
// Convert the value from a string to an integer
iCorrect=Integer.parseInt(correct);
// Create a new Question object using the parameterised constructor
Question q = new Question(question,a1,a2,a3,a4,iCorrect);
questionVector.add(q);
question = bReader.readLine();
}
// Close the file stream once we have finished reading the file
bReader.close();
}
public void setQuestion(int questNum)
{
Question q = (Question) questionVector.get(questNum);
System.out.println("Question number "+questNum+ " is "+q.getQuestion());
}
public void showQuestions()
{
for (int i=0; i< questionVector.size(); i++)
{
// Cast the object stored in the Vector to type Question
Question q = (Question)questionVector.elementAt(i);
q.printAll();
}
}
}
Now Question Frame:
// File:Question.java
// Purpose:A Java class to store a question and possible answers
public class Question
{
private String question;
private String answer1, answer2, answer3, answer4;
private int correctAnswer=0;
public Question()
{
}
public Question(String quest, String ans1, String ans2, String ans3, String ans4, int correct)
{
question = quest;
answer1=ans1;
answer2=ans2;
answer3=ans3;
answer4=ans4;
correctAnswer=correct;
}
public void printAll()
{
System.out.println(question);
System.out.println("A: " + answer1);
System.out.println("B: " + answer2);
System.out.println("C: " + answer3);
System.out.println("D: " + answer4);
System.out.println("Correct answer is answer number "+ correctAnswer);
}
public String getQuestion()
{
return question;
}
}
ok those are the codes now the hard part is making the question appear on the _private JTextField jtfquestions;_ n then having the ans place on the _private JRadioButton jrba, jrbb, jrbc, jrbd;_ then if a correct ans is inputed the JList score should move up like the game itself
this is what it looks like GUI wise
http://img164.imageshack.us/img164/6126/gui6iz.jpg
now anyone have any tips or help options?
thnks