Customize JOptionPane buttons in Java
Description
The following code shows how to customize JOptionPane buttons.
Example
// w w w .j av a 2 s. c o m
import javax.swing.JOptionPane;
public class Main {
public static void main(String[] argv) throws Exception {
String[] buttons = { "Yes", "Yes to all", "No", "Cancel" };
int rc = JOptionPane.showOptionDialog(null, "Question ?", "Confirmation",
JOptionPane.WARNING_MESSAGE, 0, null, buttons, buttons[2]);
System.out.println(rc);
}
}
The code above generates the following result.
Home »
Java Tutorial »
Swing »
Java Tutorial »
Swing »