Swing/OptionPaneButtonOrientation のバックアップの現在との差分(No.1)
- 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
概要
JOptionPane
の下部に表示されるオプションボタンの揃えを右揃えなどに変更します。
Screenshot
Advertisement
Screenshot
Advertisement
サンプルコード
解説
CENTER
UIManager.put("OptionPane.buttonOrientation", SwingConstants.CENTER)
で右揃えに変更-
MetalLookAndFeel
やWindowsLookAndFeel
でのデフォルトは、中央揃え -
MetalLookAndFeel
やWindowsLookAndFeel
でのデフォルトは中央揃え
RIGHT
UIManager.put("OptionPane.buttonOrientation", SwingConstants.RIGHT)
で右揃えに変更-
NimbusLookAndFeel
のデフォルトは、右揃え -
NimbusLookAndFeel
やGTKLookAndFeel
でのデフォルトは右揃え
LEFT
UIManager.put("OptionPane.buttonOrientation", SwingConstants.LEFT)
で左揃えに変更
- メモ
-
MotifLookAndFeel
のデフォルトは、両端揃えでUIManager.put("OptionPane.buttonOrientation", ...)
の設定は無視される
-
- -
-
MotifLookAndFeel
のデフォルトは両端揃えでUIManager.put("OptionPane.buttonOrientation", ...)
の設定は無視される -
JOptionPane#setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT)
を設定するとオプションボタンの揃えも反転する#spanend #spanadd // 例えば以下の設定で、"message"は右寄せ、オプションボタンは左寄せになる #spanend #spanadd UIManager.put("OptionPane.buttonOrientation", SwingConstants.RIGHT); #spanend #spanadd JOptionPane op = new JOptionPane("message", JOptionPane.PLAIN_MESSAGE, JOptionPane.YES_NO_OPTION); #spanend #spanadd op.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); #spanend #spanadd op.createDialog(getRootPane(), "title").setVisible(true); #spanend #spanadd