JOptionPaneのYesボタンがCancelボタンなどの中で末尾に配置されるよう設定する
Total: 2576, Today: 2, Yesterday: 0
Posted by aterai at
Last-modified:
Summary
JOptionPaneのYesボタンがCancelボタンなどの後に追加されて一番右に配置されるよう設定します。
Screenshot

Advertisement
Source Code Examples
private static final String KEY = "OptionPane.isYesLast";
JButton defaultButton = new JButton(KEY + ": false(default)");
defaultButton.addActionListener(e -> {
UIManager.put("OptionPane.isYesLast", Boolean.FALSE);
String str = JOptionPane.showInputDialog(getRootPane(), KEY + ": false");
log.setText(str);
});
JButton yesLastButton = new JButton(KEY + ": true");
yesLastButton.addActionListener(e -> {
UIManager.put("OptionPane.isYesLast", Boolean.TRUE);
String str = JOptionPane.showInputDialog(getRootPane(), KEY + ": true");
log.setText(str);
});
View in GitHub: Java, KotlinDescription
OptionPane.isYesLast: false(default)WindowsLookAndFeelでのデフォルトでYesボタン(YES_OPTION)やOKボタン(OK_OPTION)を各オプションボタンの中で先頭(左端)に配置するJOptionPane#setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT)が設定されている場合、先頭は右端に反転する
OptionPane.isYesLast: trueYesボタンを各オプションボタンの中で末尾(右端)に配置するMotifLookAndFeelやNimbusLookAndFeelでもこの設定は有効JOptionPane#setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT)が設定されている場合、末尾は左端に反転する