Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JOptionPane showConfirmDialog with only one button

I need to have only one button in showConfirmDialog.

I tried this:

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>>>>>>");
}

But this shows dialog with Yes_No_option.

I want only OK button to be displayed there. Is it possible?

like image 761
Shashank Degloorkar Avatar asked Jun 26 '12 09:06

Shashank Degloorkar


3 Answers

try using this, it creates only one button

JOptionPane.showMessageDialog(null, "Loading Complete...!!!");
like image 107
Viking Avatar answered Nov 01 '22 14:11

Viking


I want only OK button to be displayed there. Is it possible?

Use showOptionDialog() method.

    Object[] options = {"OK"};
    int n = JOptionPane.showOptionDialog(frame,
                   "Message here ","Title",
                   JOptionPane.PLAIN_MESSAGE,
                   JOptionPane.QUESTION_MESSAGE,
                   null,
                   options,
                   options[0]);
like image 45
KV Prajapati Avatar answered Nov 01 '22 14:11

KV Prajapati


It's the JOptionPane.DEFAULT_OPTION

JOptionPane.showConfirmDialog(null,
                "MESSAGE",
                "TITLE",
                JOptionPane.DEFAULT_OPTION,
                JOptionPane.PLAIN_MESSAGE);
like image 15
chromestone Avatar answered Nov 01 '22 14:11

chromestone