Skip to content

Instantly share code, notes, and snippets.

@DavidBernalGonzalez
Created May 18, 2019 21:37
Show Gist options
  • Save DavidBernalGonzalez/2465a41e9233caf032b5b71b023521f0 to your computer and use it in GitHub Desktop.
Save DavidBernalGonzalez/2465a41e9233caf032b5b71b023521f0 to your computer and use it in GitHub Desktop.
JOptionPane5
import javax.swing.JOptionPane;
public class Main {
public static void main(String[] args) {
String[] botones = {"Boton A", "Boton B", "Boton C", "Boton D"};
int ventana = JOptionPane.showOptionDialog(null,
"Pulsa un boton:",
"Javadesde0.com",
JOptionPane.DEFAULT_OPTION,
JOptionPane.QUESTION_MESSAGE, null,
botones, botones[0]);
if(ventana == 0) {System.out.println("Opcion A");}
else if(ventana == 1) {System.out.println("Boton B");}
else if(ventana == 2) {System.out.println("Boton C");}
else if(ventana == 3) {System.out.println("Boton D");}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment