Swing/AfterCheckIconGap のバックアップ(No.6)
- バックアップ一覧
- 差分 を表示
- 現在との差分 を表示
- 現在との差分 - Visual を表示
- ソース を表示
- Swing/AfterCheckIconGap へ行く。
- 1 (2019-02-25 (月) 17:39:20)
- 2 (2020-12-11 (金) 18:04:37)
- 3 (2021-05-12 (水) 07:27:14)
- 4 (2022-08-22 (月) 17:53:11)
- 5 (2025-01-03 (金) 08:57:02)
- 6 (2025-01-03 (金) 09:01:23)
- 7 (2025-01-03 (金) 09:02:38)
- 8 (2025-01-03 (金) 09:03:21)
- 9 (2025-01-03 (金) 09:04:02)
- 10 (2025-06-19 (木) 12:41:37)
- 11 (2025-06-19 (木) 12:43:47)
- category: swing folder: AfterCheckIconGap title: JCheckBoxMenuItemのチェックアイコンの位置を調整する tags: [JCheckBoxMenuItem, JMenuItem, JRadioButtonMenuItem] author: aterai pubdate: 2019-02-25T17:38:11+09:00 description: JCheckBoxMenuItemやJRadioButtonMenuItemのチェックアイコンを表示する位置を調整します。 image: https://drive.google.com/uc?id=1aRMouoW3Pw7GiH5nGdLP9r9bK8v_msLABg
Summary
JCheckBoxMenuItem
やJRadioButtonMenuItem
のチェックアイコンを表示する位置を調整します。
Screenshot

Advertisement
サンプルコード
// System.out.println(UIManager.get("CheckBoxMenuItem.checkIconOffset"));
// System.out.println(UIManager.get("CheckBoxMenuItem.afterCheckIconGap"));
// System.out.println(UIManager.get("CheckBoxMenuItem.minimumTextOffset"));
// System.out.println(UIManager.get("CheckBoxMenuItem.evenHeight"));
// UIManager.put("MenuItem.checkIconOffset", 20);
// UIManager.put("MenuItem.afterCheckIconGap", 20);
UIManager.put("MenuItem.minimumTextOffset", 20 + 20 + 31 - 9);
UIManager.put("CheckBoxMenuItem.afterCheckIconGap", 20);
UIManager.put("CheckBoxMenuItem.checkIconOffset", 20);
// UIManager.put("CheckBoxMenuItem.minimumTextOffset", 100);
View in GitHub: Java, Kotlin解説
上記のサンプルでは、JCheckBoxMenuItem
のcheckIconOffset
とafterCheckIconGap
を20
、JMenuItem
のminimumTextOffset
を62
、その他とJRadioButtonMenuItem
、JMenu
は初期値に設定してチェックアイコンの位置をテストしています。
checkIconOffset
- チェックアイコンの前のオフセット
WindowsLookAndFeel
の初期値は0
MetalLookAndFeel
、NimblsLookAndFeel
の初期値はnull
- チェックアイコンの存在しない
JMenuItem
、JMenu
でも設定可能
afterCheckIconGap
- チェックアイコンとタイトル文字列との間隔
WindowsLookAndFeel
の初期値は9
MetalLookAndFeel
、NimblsLookAndFeel
の初期値はnull
- チェックアイコンの存在しない
JMenuItem
、JMenu
でも設定可能
minimumTextOffset
- メニューのタイトル文字列までのオフセット
WindowsLookAndFeel
の初期値は31
(チェックアイコンのサイズは22
?)MetalLookAndFeel
、NimblsLookAndFeel
の初期値はnull
- この値が
checkIconOffset
とafterCheckIconGap
の合計より大きくなる場合はafterCheckIconGap
の指定が無視されて拡大する