Swing/OptionPaneButtonOrientation のバックアップの現在との差分(No.3)
- バックアップ一覧
- 差分 を表示
- 現在との差分 - Visual を表示
- ソース を表示
- バックアップ を表示
- Swing/OptionPaneButtonOrientation へ行く。
- 1 (2017-12-11 (月) 14:51:57)
- 2 (2017-12-11 (月) 16:42:00)
- 3 (2018-02-15 (木) 14:23:42)
- 4 (2019-12-08 (日) 15:27:20)
- 5 (2021-06-06 (日) 17:32:54)
- 追加された行はこの色です。
- 削除された行はこの色です。
--- category: swing folder: OptionPaneButtonOrientation title: JOptionPaneのボタンの揃えを変更する tags: [JOptionPane, UIManager, LookAndFeel] author: aterai pubdate: 2017-12-11T14:36:25+09:00 description: JOptionPaneの下部に表示されるオプションボタンの揃えを右揃えなどに変更します。 image: https://drive.google.com/uc?export=view&id=1GfIGoZXfe9MpKMUVblmQ68ek4z5tU-4cPw image: https://drive.google.com/uc?id=1GfIGoZXfe9MpKMUVblmQ68ek4z5tU-4cPw --- * 概要 [#summary] `JOptionPane`の下部に表示されるオプションボタンの揃えを右揃えなどに変更します。 #download(https://drive.google.com/uc?export=view&id=1GfIGoZXfe9MpKMUVblmQ68ek4z5tU-4cPw) #download(https://drive.google.com/uc?id=1GfIGoZXfe9MpKMUVblmQ68ek4z5tU-4cPw) * サンプルコード [#sourcecode] #code(link){{ UIManager.put("OptionPane.buttonOrientation", SwingConstants.RIGHT); }} * 解説 [#explanation] - `CENTER` -- `UIManager.put("OptionPane.buttonOrientation", SwingConstants.CENTER)`で右揃えに変更 -- `MetalLookAndFeel`や`WindowsLookAndFeel`でのデフォルトは、中央揃え -- `MetalLookAndFeel`や`WindowsLookAndFeel`でのデフォルトは中央揃え - `RIGHT` -- `UIManager.put("OptionPane.buttonOrientation", SwingConstants.RIGHT)`で右揃えに変更 -- `NimbusLookAndFeel`や`GTKLookAndFeel`でのデフォルトは、右揃え -- `NimbusLookAndFeel`や`GTKLookAndFeel`でのデフォルトは右揃え - `LEFT` -- `UIManager.put("OptionPane.buttonOrientation", SwingConstants.LEFT)`で左揃えに変更 - メモ -- `MotifLookAndFeel`のデフォルトは、両端揃えで`UIManager.put("OptionPane.buttonOrientation", ...)`の設定は無視される -- `JOptionPane#setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT)`を設定すると、オプションボタンの揃えも反転する ---- - `MotifLookAndFeel`のデフォルトは両端揃えで`UIManager.put("OptionPane.buttonOrientation", ...)`の設定は無視される - `JOptionPane#setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT)`を設定するとオプションボタンの揃えも反転する #code{{ // 例えば以下の設定で、"message"は右寄せ、オプションボタンは左寄せになる UIManager.put("OptionPane.buttonOrientation", SwingConstants.RIGHT); JOptionPane op = new JOptionPane("message", JOptionPane.PLAIN_MESSAGE, JOptionPane.YES_NO_OPTION); op.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); op.createDialog(getRootPane(), "title").setVisible(true); }} * 参考リンク [#reference] - [[JOptionPaneで使用するボタンのサイズを揃える>Swing/SameSizeButtons]] * コメント [#comment] #comment #comment