to implement a dialog, you’re still using a
behind the scenes. The reason is that
is simply acontainer that can automatically create a
and add itself to the
’s content pane.
The DialogDemo Example
Here’s a picture of an application that displays dialogs.
, you can create and customize several different kinds of dialogs.
provides support for laying out standard dialogs, providing icons, specifying the dialog’s title and text, andcustomizing the button text. Other features allow you to customize the components the dialog displays andspecify where the dialog should appear onscreen. You can even specify that an option pane put itself intoan internal frame (
) instead of a
The internal frames that
creates currently behave differently from modal dialogs.They don’t behave modally, and in general seem more like frames than like dialogs. For this reason, wedon’t currently recommend their use.
When you create a
, look-and-feel-specific code addscomponents to the
and determines the layout of thosecomponents.
’s icon support lets you easily specify which icon the dialogdisplays. You can use a custom icon, no icon at all, or any one of four standard
icons (question, information, warning, and error).Each look and feel has its own versions of the four standard icons. Thefollowing figure shows the icons used in the Java Look & Feel.
Icons provided by JOptionPane