Swing/TextShiftOffset のバックアップ差分(No.12)
- バックアップ一覧
- 現在との差分 を表示
- 現在との差分 - Visual を表示
- ソース を表示
- バックアップ を表示
- Swing/TextShiftOffset へ行く。
- 1 (2008-02-02 (土) 22:21:50)
- 2 (2008-03-12 (水) 19:33:29)
- 3 (2013-01-27 (日) 19:56:00)
- 4 (2015-07-27 (月) 19:05:31)
- 5 (2016-06-21 (火) 15:26:44)
- 6 (2016-08-15 (月) 15:30:55)
- 7 (2017-05-19 (金) 09:56:24)
- 8 (2018-05-09 (水) 15:51:27)
- 9 (2018-06-01 (金) 14:38:31)
- 10 (2018-06-02 (土) 17:06:42)
- 11 (2018-08-20 (月) 20:19:06)
- 12 (2018-09-13 (木) 15:33:04)
- 13 (2018-09-17 (月) 16:39:15)
- 14 (2020-09-18 (金) 17:12:13)
- 15 (2022-05-18 (水) 06:22:13)
- 16 (2024-03-02 (土) 18:55:49)
- 追加された行はこの色です。
- 削除された行はこの色です。
---
category: swing
folder: TextShiftOffset
title: JButtonのテキストシフト量を変更
tags: [JButton, UIManager]
author: aterai
pubdate: 2007-12-31T16:51:19+09:00
description: JButtonをクリックしたときのテキストシフト量を変更します。
image: https://lh6.googleusercontent.com/_9Z4BYR88imo/TQTVR92SsdI/AAAAAAAAAnY/_wKFJTNu2oY/s800/TextShiftOffset.png
---
* 概要 [#summary]
`JButton`をクリックしたときのテキストシフト量を変更します。
#download(https://lh6.googleusercontent.com/_9Z4BYR88imo/TQTVR92SsdI/AAAAAAAAAnY/_wKFJTNu2oY/s800/TextShiftOffset.png)
* サンプルコード [#sourcecode]
#code(link){{
UIManager.put("Button.textShiftOffset", 0);
SwingUtilities.updateComponentTreeUI(this);
}}
* 解説 [#explanation]
上記のサンプルでは、`JButton`をクリックした際に、あわせて内部の文字列が移動する距離を、`0`、`1`、`-1`と切り替えることができます。
- `JButton`に設定した`Icon`は文字列と同様に移動するが、文字列が`HTML`テキストの場合は無効で移動しない
- `JToggleButton`などには、効果がない
-- `UIManager.put("ToggleButton.textShiftOffset", 1)`なども無効
- `Java 1.5.0` + `WindowsLookAndFeel`のデフォルトは`1`
- `Java 1.6.0` + `WindowsLookAndFeel`のデフォルトは`0`
- `JTabbedPane`のタブは、`TabbedPane.selectedLabelShift`と`TabbedPane.labelShift`でテキストシフト量を変更可能
* 参考リンク [#reference]
- [[ConvolveOpでコンポーネントにぼかしを入れる>Swing/BlurButton]]
-- %%`ToggleButton.textShiftOffset`を考慮しておかないと、ボタンの端にブラー効果が適用されない?%% 無関係
* コメント [#comment]
#comment
#comment