| 
import javax.swing.*;    //import line to load the libray/package that
 import java.io.*;                         //has the swing GUI components.
 
 public class SwifhgfjfjdngGUI
 {
 
 
 public static void main(String[] args)
 {
 
 int x1,score;
 
 x1=0;
 score = 0;
 
 //This is the code to disply the msg box.
 //JOptionPane.showMessageDialog(null, "This quiz is about Java, I hope you're prepared.", "JavaQuiz!", JOptionPane.WARNING_MESSAGE);
 //The 1st argument for the dialog is for a parent component, when no parent component is used you put it as null
 //The last argument is for the icon to be displayed with the dialog.
 //Thess are the comanan icons used in Java:
 //WARNING_MESSAGE
 //ERROR_MESSAGE
 //INFORMATION_MESSAGE
 //PLAIN_MESSAGE
 //QUESTION_MESSAGE
 
 /*Note: JOptionPane.showMessageDialog can be shorted to*/ JOptionPane.showMessageDialog(null,"This quiz is about Java, I hope you're prepared.");
 //if no title or icon setings are whonted or needed.
 
 System.out.println("A. What is the library you import into Java,uasually, at the begining of the Program?");
 System.out.println("1) java.oi.#");
 System.out.println("2) java.io.&");
 System.out.println("3) java.io.*");
 System.out.println("4) java.io.#");
 
 String uInput; //a varibale to store the users input
 
 //the JOptionPane.showInputDialog fuction returns a string of the users input
 uInput = JOptionPane.showInputDialog(null, "Type your answer here.(1, 2, 3, or 4)", "Answer Box", JOptionPane.ERROR_MESSAGE);
 //As with the msg Dialog the 1st argument is for a parent component and the last for
 //an icon to go with the dialog. (see posable icons under msg dialog)
 //The JOptionPane.showInputDialog fuction can be shortend to JOptionPane.showInputDialog("msg to show user")
 //if no other arrments are needed.
 //If the user hits Cancel insted of OK the return value will be null
 
 //Note: the string responce can be conveted to an other tpye if need
 //i may add how to do this in an update of this tutorale latter.
 
 //uInput=Integer.parseInt(x1);
 
 
 if (uInput == 1)
 {
 score = score+0;
 
 }
 else if (uInput == 2)
 {
 score = score+0;
 }
 else if (uInput == 3)
 {
 score = score+1;
 }
 else if (uInput == 4)
 {
 score = score+0;
 }
 
 System.out.println(" ");
 System.out.println("Next Question");
 System.out.println(" ");
 
 }
 }
 
 |