JOptionPane showConfirmDialog with only one button
java, joptionpane, swing
Solution
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]);
Problem
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?