This is the Text, it won't work I allready checked it with the You AI
import javax.swing.JOptionPane;
public class Test_showConfirmDialog1 {
public static void main(String[] args) {
Object[] options = {"Yes", "No"};
int Tester = JOptionPane.showConfirmDialog(null, "Do you smoke?", "",
JOptionPane.DEFAULT_OPTION,JOptionPane.WARNING_MESSAGE, null, options, options[0]);
JOptionPane.showMessageDialog(null, "Tester = " + Tester);
}
Eclipse says: show.ConfirmDialog doesn't work. why? (I am a Beginner, I don't know most of Java but the code simply corrected woould be allready helpfull, I am sure I will figure out the rest by myself.)
It's because you use
showConfirmDialog, instead of usingshowOptionDialog.Here is the code that is using the
showOptionDialog:If you only want to use Yes or No options, Java swing has a built-in dialog for that (it uses
showConfirmDialog):I hope it helped.