次のコードは、ボタンがないことを除けば、期待どおりのダイアログを示しています。
final JPasswordField passwdField = new JPasswordField();
passwdField.setColumns(20);
final JComponent[] inputs = new JComponent[] { passwdField };
int res = JOptionPane.showOptionDialog(null, "Enter Password", "Login",
JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE,
null, inputs, "");
次のダイアログを表示します(Java 6.2?、Windows 7 64ビット):
OK /キャンセルボタンがないのはなぜですか?(ところで、ダイアログはサイズ変更できないので、表示されているフレームのすぐ外側にあるかどうかはわかりません)
(また、Enterキーを押してもダイアログは閉じません。「x」を押すとダイアログが閉じます)