• Post Reply Bookmark Topic Watch Topic
  • New Topic

OptionDialog Problem  RSS feed

 
Kinu Kanwar
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having a very basic problem , Please help me .

I have Option Dialog with two options A and B . If user selects neither A nor B but click cross to close dialog box , My program continues. Just want to disable that cross button that is used to close the window.

I want user to make selction A or B and should not be able to close the option window before that . Is ther any way ??

My code goes as follows .....



Object[] options = {"Change to A", "Continue with B" };


int response = JOptionPane.showOptionDialog(
null ,
"A or B" ,
"Confirm",JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
null,
options,
options[1]
);

if (response == JOptionPane.YES_OPTION)
{
// do some thing
return ;
}

// continue with your logic
}
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
run your program and hit the 'escape' key.
if it has the same effect as the 'X', you might be wasting your time
trying to remove the 'X'.
 
Tad Dicks
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could run the dialog inside of a loop.
String response = null;
while(response == null)
{
response = Dialog.getResponse();
}

er something like that....
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!