JOptionPane showConfirmDialog Code Example
Previously i wrote JOptionPane showOptionDialog example.Here is JOptionPane showConfirmDialog Code Example.
See also:
JOptionPane showConfirmDialog Java Example Code
[
import javax.swing.JOptionPane; public class ShowConfirmDialog { public static void main(String args[]) { exitAction(); } public static void exitAction() { String message = "There are commands in the output buffer - really quit?"; String title = "Really Quit?"; // display the JOptionPane showConfirmDialog
int reply = JOptionPane.showConfirmDialog(null, message, title, JOptionPane.YES_NO_OPTION); if (reply == JOptionPane.YES_OPTION) { System.exit(0); } } }
]
JOptionPane showConfirmDialog Code Analysis
exitAction() method is declared static because its used inside static method.Note that no variable or method that is not static that can be used inside a static method.