Наиболее сложным из диалоговых окон является возможность диалоговое окно, которое сочетает в себе черты всех других диалогов (Подтвердите диалоговое окно, Входной диалоговом окне, и появится диалоговое окно). Она может быть создана с showOptionDialog (Component, Object, String, INT, INT, иконы, Object [], объект) класса JOptionPane.
Аргументы для этого метода являются следующие:
- The parent component of the dialog
- The text, icon or component to display
- A string to display in the title bar
- The type of box, using the class constants YES_NO_OPTION or YES_NO_CANCEL_OPTION, or
the literal 0 if other buttons will be used instead. - The icon to display, using the class constants ERROR_MESSAGE, INFORMATION_MESSAGE,
PLAIN_MESSAGE, QUESTION_MESSAGE or WARNING_MESSAGE, or the literal 0 if none of these
will be used. - An Icon object to display instead of one of the icons in the preceding argument
- An array of objects holding the components or other objects that represent the choices
in the dialog box. (if YES_NO_OPTION and YES_NO_CANCEL_OPTION are not being used.) - The object representing the default selection. (if YES_NO_OPTION and YES_NO_CANCEL_OPTION
are not being selected.)
Следующий пример создает опцию диалоговое окно, которое используется массив объектов JButton для ссылок в окне и цвет [3], а выбор по умолчанию:
|