I dont know how to kill this JOptionPane pop out eveytime i do something... it just pops
Object[] options = {"Option 1",
"Option 2"};
Component frame = null;
int n = JOptionPane.showOptionDialog(frame,
"Chose Game Option \n *Option 1 - Enter Secret Word\n *Option 2 - Random word selection from secret list",
"Chose game mode",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
null, //do not use a custom Icon
options, //the titles of buttons
options[0]); //default button title
Some lines below that i have this
private void TryLetterActionPerformed(java.awt.event.ActionEvent evt) {
String letter = aLetter.getText();
int charPos = 0;
if(n == JOptionPane.YES_OPTION)
{
String text = (String)evt.getActionCommand();
if (text.equals("Start"))
{
TryLetter.setText("Try letter");
}
String FindWord = JOptionPane.showInputDialog(null,"Enter secret word");
MyMessage.setText("position is" + charPos);
charPos = FindWord.indexOf(letter);
if(charPos == 0) Char1.setText(letter);
if(charPos == 1) Char2.setText(letter);
if(charPos == 2) Char3.setText(letter);
if(charPos == 3) Char4.setText(letter);
if(charPos == 4) Char5.setText(letter);
if(charPos == 5) Char6.setText(letter);
}
if(n == JOptionPane.NO_OPTION)
{
System.out.println("haha");
}
basicly what i'm tryting to achive here is run program, window pops out with 2 options when you click option one then you enter a words that is going to be used in this aplication(game), and then you start playing, what happens though is you enter word, and when you click on Tryletter button this JOption pops out asking you to enter word again, and its like a loop does it all the time you click a button try letter... how to solve this ? so i enter word ONCE and i can start playing ?
Also when i put this JOption so its global, then i have bunch of errors on whole aplication