---
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
---
* 概要 [#summary]
`JOptionPane`の下部に表示されるオプションボタンの揃えを右揃えなどに変更します。

#download(https://drive.google.com/uc?export=view&id=1GfIGoZXfe9MpKMUVblmQ68ek4z5tU-4cPw)

* サンプルコード [#sourcecode]
#code(link){{
UIManager.put("OptionPane.buttonOrientation", SwingConstants.RIGHT);
}}


* 解説 [#explanation]
- `CENTER`
-- `UIManager.put("OptionPane.buttonOrientation", SwingConstants.CENTER)`で右揃えに変更
-- `MetalLookAndFeel`や`WindowsLookAndFeel`でのデフォルトは、中央揃え
- `RIGHT`
-- `UIManager.put("OptionPane.buttonOrientation", SwingConstants.RIGHT)`で右揃えに変更
-- `NimbusLookAndFeel`のデフォルトは、右揃え
- `LEFT`
-- `UIManager.put("OptionPane.buttonOrientation", SwingConstants.LEFT)`で左揃えに変更
- メモ
-- `MotifLookAndFeel`のデフォルトは、両端揃えで`UIManager.put("OptionPane.buttonOrientation", ...)`の設定は無視される

* 参考リンク [#reference]
- [[JOptionPaneで使用するボタンのサイズを揃える>Swing/SameSizeButtons]]

* コメント [#comment]
#comment
#comment