i want to disable the NO and CANCEL option , can you guys help me because im only a begineer of JOPTION here is ma code: btw this is my assignment in my 1st year college "compro" my teacher tell us to create a program , and my system is QUESTION and ANSWER my problem is there was a NO and CANEL option what if the teacher click it then the null will appear , (all i need is, if the teacher click the NO or CANCEL the program will exit .)

import javax.swing.*;
import java.io.*;
public class QA
{
    public static void main(String[]args)throws IOException{

    DataInputStream m = new DataInputStream(System.in);

        JFrame frame = new JFrame("Message");

    JOptionPane.showMessageDialog(frame,
        "WELCOME TO THE WORLD OF JAVA");

    String name= JOptionPane.showInputDialog
    ("Enter your Full Name");

    JOptionPane.showConfirmDialog(null, 
    "Are you Ready"+name, "Choose answer", JOptionPane.YES_NO_OPTION);

        Object[] possibleValues = { "Select answer below","__________",
        "computer", "hardware", "software", "jboy", "rommel", "warren"};
        Object selectedValue = JOptionPane.showInputDialog(null,    
        "It is an electronical device capable of performing complex computations is a short time?", 
        "QUESTION 1",JOptionPane.INFORMATION_MESSAGE, null,possibleValues, possibleValues[0]);

        String choice = selectedValue.toString();
        String answer = "computer";

        if (choice.equals(answer)){

            Object[] options = { "OK", "CANCEL" };
            JOptionPane.showOptionDialog(null, "Your Answer is Correct", "Congrats", 
            JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE,
            null, options, options[0]);

        }else{

            JOptionPane.showMessageDialog(null, "Your answer is wrong", "Owh-owh", JOptionPane.ERROR_MESSAGE); 

        }

        JFrame frames = new JFrame("Message");

        // show a joptionpane dialog using showMessageDialog
         JOptionPane.showMessageDialog(frame,
        "Click OK to proceed for next question");

        Object[] possibleValues1 = { "Select answer below","__________",
        "rommel", "warren", "jboy" };
        Object selectedValue1 = JOptionPane.showInputDialog(null,   
        "WHO'S LOOK A LIKE OF MR.BEAN?", 
        "QUESTION 2",JOptionPane.INFORMATION_MESSAGE, null,possibleValues, possibleValues[0]);

        String choices = selectedValue.toString();
        String answers = "jboy";

        if (choice.equals(answer)){

            Object[] options = { "OK", "CANCEL" };
            JOptionPane.showOptionDialog(null, "Your Answer is Correct", "Congrats", 
            JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE,
            null, options, options[0]);

        }else{

            JOptionPane.showMessageDialog(null, "Your answer is wrong", "Owh-owh", JOptionPane.ERROR_MESSAGE); 

        }



         System.exit(0);











    }
}

Do some reading on JOptionPane. The answers are in that article. Next time post your code in code blocks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.