• category: swing folder: TabbedPaneLabelShift title: JTabbedPaneのタブのテキストシフト量を変更する tags: [JTabbedPane, UIManager] author: aterai pubdate: 2018-09-17T16:31:38.295+09:00 description: JTabbedPaneの選択状態でのタブテキストシフト量などを変更します。 image: https://drive.google.com/uc?id=1h-7B_-q-8VbEv-cpGzX6hQFdOcf8KgT9LA

概要

JTabbedPaneの選択状態でのタブテキストシフト量などを変更します。

サンプルコード

UIManager.put("TabbedPane.selectedLabelShift", -1);
UIManager.put("TabbedPane.labelShift", 1);
View in GitHub: Java, Kotlin

解説

上記のサンプルでは、Java 1.8.0から導入されたTabbedPane.selectedLabelShiftTabbedPane.labelShiftJTabbedPaneのタブテキストシフト量を変更するテストができます。

テキストだけではなく、タブアイコンや、`JTabbedPane#setTabComponentAt(...)で設定したタブコンポーネントも同様に移動します。

  • TabbedPane.selectedLabelShift
    • 選択状態タブのテキストシフト量
    • デフォルトのタブ位置(JTabbedPane.TOP)の場合、マイナスで上方向、プラスで下方向に移動
    • WindowsLookAndFeelでのデフォルトは-1
  • TabbedPane.labelShift
    • 非選択状態タブのテキストシフト量
    • デフォルトのタブ位置(JTabbedPane.TOP)の場合、マイナスで上方向、プラスで下方向に移動
    • WindowsLookAndFeelでのデフォルトは1

参考リンク

コメント