Recently I have been working on a eclipse project in my AP Computer Science class at school. My goal is to create a game like Simon says, using JOptionPane windows. I have the good idea of what I need to do, except my one problem is that when I want to close the "Simon Says" windows very quickly so the user cannot fully read the message. I believe I will have to use swing timers from what I've been looking for. A response with a fixed code would be great, I am just a beginner currently. So if you add the timer in, please add it to easy level. Thank you so much!
import javax.swing.JOptionPane;
public class Random {
public static void main(String[] args) {
JOptionPane.showMessageDialog(null, "Welcome." );
JOptionPane.showInputDialog("Enter a nickname to play");
String[] choices = { "EASY", "HARD" };
String input = (String) JOptionPane.showInputDialog(null, "Choose now...",
"Difficulty", JOptionPane.QUESTION_MESSAGE, null,
choices, // Array of choices
choices[1]); // Initial choice
JOptionPane.showMessageDialog(null, "Your difficulty is " + input);
//For easy
if (input.equals("EASY"))
{
JOptionPane.showMessageDialog(null, "To play, click OK. A message bubble will come up, and have a command with either the words JAVA SAYS at the begginning, or with out the words. \nThe message bubble will be up for one half of a second and you will have to see if the beginning words are there. \nIf the words are there before the action, the correct thing to do is click the action and proceed. \nIf the words are not there, click the option to do nothing and proceed. If you fail to choose the correct choice, you will lose the game and have to restart.", "Instructions", JOptionPane.QUESTION_MESSAGE); //instructions here
{
JOptionPane.showOptionDialog(null, "Java says","Java Says", JOptionPane.DEFAULT_OPTION,JOptionPane.INFORMATION_MESSAGE, null, new Object[]{}, null);
}
}
// For Hard level
if (input.equals("HARD"))
{
JOptionPane.showMessageDialog(null, "To play, click OK. A message bubble will come up, and have a command with either the words JAVA SAYS at the begginning, or with out the words. \nThe message bubble will be up for one fourth of a second and you will have to see if the beginning words are there. \nIf the words are there before the action, the correct thing to do is click the action and proceed. \nIf the words are not there, click the option to do nothing and proceed. If you fail to choose the correct choice, you will lose the game and have to restart.", "Instructions", JOptionPane.QUESTION_MESSAGE); //instructions here
}
}
}