Is it possible to mount two ImageIcon in a JOptionPane?

1

I would like two images to appear in a single JOptionPane of either input or message.

Object seleccion = JOptionPane.showInputDialog( null, "Seleccion Respuesta Correcta",
                          "Preguntas",JOptionPane.QUESTION_MESSAGE,
                          new ImageIcon("imagenes/img1.png"),
                          new Object[] { "opcion 1", "opcion 2" }, 
                       "");
    
asked by Alejandro Cast 04.07.2017 в 22:30
source

1 answer

1

can be used type constructor (Componente,Objeto,String,int) where the component will be the parent window (for example only null) , the object parameter is one Array of JLabel which will be the images, The third will be the Title of the dialogue and the int refers to the type of message by icono .

JLabel[] arr = {
      new JLabel("",new ImageIcon("rutaimagen1"),JLabel.LEFT),
      new JLabel("",new ImageIcon("rutaimagen2"),JLabel.RIGHT)
      };
JOptionPane.showMessageDialog(null,arr,"Mensaje!!", JOptionPane.INFORMATION_MESSAGE);
String valor = JOptionPane.showInputDialog(null, arr, "Ingrese Valor",
                                           JOptionPane.WARNING_MESSAGE);
System.out.println(valor);
    
answered by 04.07.2017 / 23:18
source