Customize JOptionPane in Java
Description
The following code shows how to customize JOptionPane.
Example
/*from ww w. j a va2 s.c om*/
import javax.swing.JButton;
import javax.swing.JOptionPane;
public class Main {
public static void main(String[] args) {
Object msg[] = { "Complex Message", new JButton("A component"),
new Object[] { " Nested", " Array" }, "for JOptionPane" };
Object type[] = { "Animal", "Vegetable", "Mineral" };
int result = JOptionPane.showOptionDialog(null, msg, "Choose",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, type,
null);
System.out.println("Result (index)= " + result + " (" + type[result] + ")");
}
}
The code above generates the following result.
Home »
Java Tutorial »
Swing »
Java Tutorial »
Swing »