Create dialog with default options with JOptionPane in Java
Description
The following code shows how to create dialog with default options with JOptionPane.
Example
import java.awt.Component;
// ww w .j a v a 2 s .c o m
import javax.swing.JOptionPane;
public class Main {
public static void main(String[] argv) throws Exception {
int i = ok("Done.");
System.out.println("ret : " + i);
}
public static int ok(String theMessage) {
int result = JOptionPane.showConfirmDialog((Component) null, theMessage,
"alert", JOptionPane.DEFAULT_OPTION);
return result;
}
}
The code above generates the following result.
Home »
Java Tutorial »
Swing »
Java Tutorial »
Swing »