• 追加された行はこの色です。
  • 削除された行はこの色です。
---
category: swing
folder: InvertedSlider
title: JSliderの順序を反転
tags: [JSlider]
author: aterai
pubdate: 2014-02-10T00:01:53+09:00
description: JSliderの値や目盛りの表示などの順序を反転します。
image: https://lh6.googleusercontent.com/-qI_Mv8LOhi8/UvdK3TThMiI/AAAAAAAAB_0/xQR9OJ1Z8xY/s800/InvertedSlider.png
---
* 概要 [#summary]
`JSlider`の値や目盛りの表示などの順序を反転します。

#download(https://lh6.googleusercontent.com/-qI_Mv8LOhi8/UvdK3TThMiI/AAAAAAAAB_0/xQR9OJ1Z8xY/s800/InvertedSlider.png)

* サンプルコード [#sourcecode]
#code(link){{
slider.setInverted(true);
}}

* 解説 [#explanation]
上記のサンプルでは、`JSlider#setInverted(true)`で、値や目盛りの表示を反転しています。
上記のサンプルでは、`JSlider#setInverted(true)`で、値や目盛りの表示位置を反転しています。

----
- `JSlider#setInverted(true)`と`setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT)`で言語に依存する方向を同時に指定可能
-- `SwingConstants.HORIZONTAL`の場合、両方指定すると元に戻る
-- `SwingConstants.VERTICAL`の場合、`JSlider#setInverted(true)`で上最小、下最大に変化し、`setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT)`で目盛りの位置が右から左に変化する
- 範囲の塗り潰しが可能な`MetalLookAndFeel`の場合、これも反転する
- 縦の`JSlider`で`ComponentOrientation.RIGHT_TO_LEFT`、`WindowsLookAndFeel`を設定した場合、ノブのフォーカスが描画されない

//* 参考リンク [#reference]
* 参考リンク [#reference]
- [https://docs.oracle.com/javase/jp/8/docs/api/javax/swing/JSlider.html#setInverted-boolean- JSlider#setInverted(boolean) (Java Platform SE 8)]

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