2012-06-26 39 views
13

Necesito tener solo un botón en showConfirmDialog.JOptionPane showConfirmDialog con un solo botón

yo probamos este:

int response = JOptionPane.showConfirmDialog(null, "Time Entered Successfully", 
        "", JOptionPane.OK_OPTION, JOptionPane.PLAIN_MESSAGE); 

if (response == JOptionPane.CLOSED_OPTION || response == JOptionPane.OK_OPTION) 
{ 
    System.out.println("CLOSING>>>>>>"); 
} 

Pero esta muestra de diálogo con YES_NO_OPTION.

Solo quiero mostrar el botón OK allí. ¿Es posible?

Respuesta

17

Solo quiero mostrar el botón OK allí. ¿Es posible?

Use showOptionDialog() method.

Object[] options = {"OK"}; 
    int n = JOptionPane.showOptionDialog(frame, 
        "Message here ","Title", 
        JOptionPane.PLAIN_MESSAGE, 
        JOptionPane.QUESTION_MESSAGE, 
        null, 
        options, 
        options[0]); 
+0

bien mal vamos u conocer gracias –

+0

que trabajaron .. :) –

20

tratar de usar esto, se crea un solo botón

JOptionPane.showMessageDialog(null, "Loading Complete...!!!"); 
+0

funcionaba perfecto, gracias tú – AMB

8

Es la JOptionPane.DEFAULT_OPTION

JOptionPane.showConfirmDialog(null, 
       "MESSAGE", 
       "TITLE", 
       JOptionPane.DEFAULT_OPTION, 
       JOptionPane.PLAIN_MESSAGE); 
Cuestiones relacionadas