Check out example codes for "JOptionPane with drop down list java". It will help you in understanding the concepts better.

Code Example 1

package com.mkyong.inputDialog;

import javax.swing.ImageIcon;
import javax.swing.JOptionPane;

public class InputDialog6a {

    public static void main(String[] args) {

        String[] options = {"I adore turtles", "Yes", "Maybe", "Urm...", "No", "Hate them"};
        ImageIcon icon = new ImageIcon("src/images/turtle32.png");
        String n = (String)JOptionPane.showInputDialog(null, "Do you like turtles??", 
                "I like turtles", JOptionPane.QUESTION_MESSAGE, icon, options, options[2]);
        System.out.println(n);

    }

}
Copy

Learn ReactJs, React Native from akashmittal.com