help with buttons.. plzz
Author |
Message |
poo
|
Posted: Sun Jan 18, 2009 3:21 pm Post subject: help with buttons.. plzz |
|
|
hey everyone.. i m making a mini quiz type game...... this is wht i have soo far.
Java: | import java.awt.Checkbox;
import java.awt.CheckboxGroup;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.Label;
import java.io.*;
//import java.awt.event.*;
import java.util.*;
public class RadioButtonTest
{
public static void main (String[] args ) throws IOException
{
// c = new Console ();
// new RadioButtonTest ();
String[] [] text = new String [7] [6]; // making a multidimensional array
File file = new File ("original.txt"); //reading in the file
BufferedReader bufRdr = new BufferedReader (new FileReader (file ));
String line = null;
int row = 0;
int col = 0;
//reads each line of text file
while ((line = bufRdr. readLine ()) != null && row <= 7)
{
StringTokenizer st = new StringTokenizer (line, "@"); //splits it everytime it hits a @ symbol
while (st. hasMoreTokens ())
{
//get next token and store it in the array
text [row ] [col ] = st. nextToken ();
col++;
}
col = 0;
row++;
}
int i = (int) (Math. random () * 6); //radomizing the questions
for (int j = 0 ; j < 5 ; j++ ) //making it less than 5.. makes sure that the right answer does not print.
{
}
//print statements to display the question and the appropriate answers.
System. out. println (text [i ] [0]);
System. out. print ("A:");
System. out. println (text [i ] [1]);
System. out. print ("B:");
System. out. println (text [i ] [2]);
System. out. print ("C:");
System. out. println (text [i ] [3]);
System. out. print ("D:");
System. out. println (text [i ] [4]);
System. out. println (" ");
Frame f = new Frame ("QUIZ GAME");
Label l1 = new Label ("PLEASE CHOOSE YOUR ANSWER?");
f. setLayout (new GridLayout (0, 1));
CheckboxGroup group = new CheckboxGroup ();
f. add (l1 );
f. add (new Checkbox ("A", group, true));
f. add (new Checkbox ("B", group, false));
f. add (new Checkbox ("C", group, false));
f. add (new Checkbox ("D", group, false));
f. setSize (250, 200);
f. setVisible (true);
f. pack ();
f. addWindowListener (new WindowAdapter ()
{
public void windowClosing (WindowEvent we )
{
System. exit (0);
}
}
);
// Place your program here. 'c' is the output console
}
} |
and here is ma text file..........
what is the flame that continually remain lite in many older-model gas stove?@stove candle@bunt flame@pilot light@rocket engine@bunt flame@
A hidden resource saved for use at a critical time is called a wht "in the hole"?@map@ace@candle@lifeline@candle@
A cadiology specializes in wht part of the human body?@eyes@heart@hair@ears@heart@
What does a pH level measure?@humidity@density@acidity@Wavelength@acidity@
Which of these holidays is not attached to a specific date?@Christmas@IndependenceDay@Thanksgiving@NewYear'sDay@christmas@
What famous radio personality was also the voice of Shaggy on the cartoon 'Scooby-Doo'?@Rush Limbaugh@Casey Kasem@Larry King@Bob@Larry King@
What type of substance is 'terra-cotta'?@glass@metal@ceramic@wood@wood@
THE TXT FILE... THE FIRST ELEMENT IS THE QUESTION FOLLOWED BY 4 CHOICES AND THEN THE LAST ELEMENT IS THE CORRECT ANSWER..
1) SO WHEN I RUN THIS PROGRAM THE QUESTIONS ARE DISPLAYIN IN ONE CONSOLE AND THE RADIO BUTTONS ARE COMING IN ANOTHER CONSOLE HOW DO I COMBING THEM?
2) THEN HOW DO I PUT THE 2DARRAY VALUES TO THE RADIO BUTTON TO COMPARE THEM WITH THE RIGHT ANSWER??
plzzzzzzzzzzzzzzzzzzz HELPPP
Mod Edit: Remember to use syntax tags! Thanks code: | [syntax="java"]Code Here[/syntax] |
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
|
|