Created
April 21, 2020 20:11
-
-
Save benjjo/e6f73edc38ea9a542b1f293d5ead3227 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.swing.JCheckBox; | |
import javax.swing.JOptionPane; | |
public class ConfirmDialog1b { | |
public static void main(String[] args) { | |
JCheckBox check = new JCheckBox("Tick me"); | |
Object[] options = {'e', 2, 3.14, 4, 5, "TURTLES!", check}; | |
int x = JOptionPane.showOptionDialog(null, "So many options using Object[]", | |
"Don't forget to Tick it!", | |
JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, null, options, options[0]); | |
if (check.isSelected() && x != -1) { | |
System.out.println("Your choice was " + options[x]); | |
} else { | |
System.out.println(":( no choice"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment