• 追加された行はこの色です。
  • 削除された行はこの色です。
---
category: swing
folder: TabbedPaneUseBasicArrows
title: NimbusLookAndFeelでJTabbedPaneのスクロール矢印ボタンを変更する
tags: [NimbusLookAndFeel, JTabbedPane, ArrowButton]
tags: [NimbusLookAndFeel, JTabbedPane, ArrowButton, UIManager]
author: aterai
pubdate: 2022-09-05T03:34:14+09:00
description: NimbusLookAndFeelを適用したJTabbedPaneのスクロール矢印ボタンがBasicArrowButtonかSynthArrowButtonのどちらを使用するかを切り替えます。
image: https://drive.google.com/uc?id=1kL0AppkB4JwnMPqMOEcChAIp3L58NV3F
---
* 概要 [#summary]
NimbusLookAndFeelを適用したJTabbedPaneのスクロール矢印ボタンがBasicArrowButtonかSynthArrowButtonのどちらを使用するかを切り替えます。
`NimbusLookAndFeel`を適用した`JTabbedPane`のスクロール矢印ボタンが`BasicArrowButton`か`SynthArrowButton`のどちらを使用するかを切り替えます。

#download(https://drive.google.com/uc?id=1kL0AppkB4JwnMPqMOEcChAIp3L58NV3F)

* サンプルコード [#sourcecode]
#code(link){{
JTabbedPane tabs = new JTabbedPane();
tabs.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
IntStream.range(0, 100).forEach(i -> tabs.addTab("title" + i, new JLabel("label" + i)));

String key = "TabbedPane.useBasicArrows";
// UIManager.put(key, Boolean.FALSE);
// UIManager.put("ArrowButton.size", 24);

JCheckBox check = new JCheckBox(key, UIManager.getBoolean(key));
check.addActionListener(e -> {
  boolean b = ((JCheckBox) e.getSource()).isSelected();
  UIManager.put(key, b);
  SwingUtilities.updateComponentTreeUI(tabs);
});
}}

* 解説 [#explanation]
- `TabbedPane.useBasicArrows: Boolean.TRUE`
-- `NimbusLookAndFeel`のデフォルトで`JTabbedPane`のスクロール矢印ボタンとして`BasicArrowButton`を使用する
- `TabbedPane.useBasicArrows: Boolean.FALSE`
-- `JTabbedPane`のスクロール矢印ボタンとして`SynthArrowButton`を継承した`SynthScrollableTabButton`を使用する
-- `UIManager.put("ArrowButton.size", 24)`などでスクロール矢印ボタンのサイズ変更が可能

* 参考リンク [#reference]
- [[JSpinnerのArrowButtonのサイズを変更>Swing/SpinnerArrowButtonSize]]

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