JOptionPane.showOptionDialog(
null
, "Pergunta?" // Mensagem
, "Titulo" // Titulo
, JOptionPane.YES_NO_OPTION
, JOptionPane.PLAIN_MESSAGE
, null // Icone. Você pode usar uma imagem se quiser, basta carrega-la e passar como referência
, opcoes // Array de strings com os valores de cada botão. Veja o exemplo abaixo **
, "Botao 3" // Label do botão Default
);
options can be declared as such:
String[] choices = {"Botao 1", "Botao 2", "Botao 3", "Botao 4"};
The Parent Component is only to guide the Dialog to which window it belongs, in this way it will position itself in relation to it. We usually use NULL to get it in the center of the Desktop.
To display an image you can use a Bufferedimage.
Joptionpane.YES_NO_OPTION : If you pass NULL instead of options your dialog will have 'YES', 'No' and 'Cancel' buttons'
Joptionpane.PLAIN_MESSAGE is the type of message you will display. This one is a type of message with a custom icon (by icon parameter). There are other:
JOptionPane.PLAIN_MESSAGE
JOptionPane.ERROR_MESSAGE
JOptionPane.INFORMATION_MESSAGE
JOptionPane.WARNING_MESSAGE
JOptionPane.QUESTION_MESSAGE
JOptionPane.PLAIN_MESSAGE (sem icone)
But it can explain separately what would be Parentcomponent?
– Isaac Reinaldo