Quantcast
Channel: How to use JOptionPane with many options? java - Stack Overflow
Viewing all articles
Browse latest Browse all 3

How to use JOptionPane with many options? java

$
0
0

I was experimenting with different JOptionPane and I came across having different options in a array and then using it on JOptionPane. However I am finding it hard to use the given options, so for example, how would I use my GO back option?

  String[] options = new String[] {"Go ahead", "Go back", "Go forward", "close me"};      int option =  JOptionPane.showOptionDialog(null, "Title", "Message",             JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE,            null, options, options[0]);

I have tried doing it like this but it won't work

    if (option == JOptionPane.options[1]){    }

edit:

 switch(option){          case 1: System.out.println("1");              break;          case 2: System.out.println("2");              break;          case 3: System.out.println("3");              break;          case 4: System.out.println("4");              break;          }

Viewing all articles
Browse latest Browse all 3

Trending Articles





<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>