---
category: swing
folder: InternalFrameTitleButtonToolTipsOn
title: JInternalFrameのTitleButtonでJToolTipを表示するかを切り替える
tags: [UIManager, JInternalFrame, JButton, JToolTip, WindowsLookAndFeel]
author: aterai
pubdate: 2023-02-13T01:33:32+09:00
description: JInternalFrameのタイトルバーに配置された閉じる、最大化、最小化ButtonでJToolTipの表示・非表示を切り替えます。
image: https://drive.google.com/uc?id=1SLM6oYpp38PKBED36pr5cj4VOAeXEq4I
---
* 概要 [#summary]
JInternalFrameのタイトルバーに配置された閉じる、最大化、最小化ButtonでJToolTipの表示・非表示を切り替えます。

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

* サンプルコード [#sourcecode]
#code(link){{
String key = "InternalFrame.titleButtonToolTipsOn";
boolean def = UIManager.getLookAndFeelDefaults().getBoolean(key);
JCheckBox check = new JCheckBox(key, def) {
  @Override public void updateUI() {
    super.updateUI();
    setOpaque(false);
    boolean b = UIManager.getLookAndFeelDefaults().getBoolean(key);
    setSelected(b);
    UIManager.put(key, b);
    SwingUtilities.updateComponentTreeUI(desktop);
  }
};
check.addActionListener(e -> {
  JCheckBox checkBox = (JCheckBox) e.getSource();
  UIManager.put(key, checkBox.isSelected());
  SwingUtilities.updateComponentTreeUI(desktop);
});
}}

* 解説 [#explanation]
- `InternalFrame.titleButtonToolTipsOn: true`
-- `WindowsLookAndFeel`のデフォルト
-- `WindowsLookAndFeel.java`で`Object hotTrackingOn = new WindowsDesktopProperty("win.item.hotTrackingOn", true);`と`Windows`デスクトップのプロパティ変更と連動してメニューバーのロールオーバーとも連動している?
--- `"InternalFrame.titleButtonToolTipsOn", hotTrackingOn,`
--- `"MenuBar.rolloverEnabled", hotTrackingOn,`
- `InternalFrame.titleButtonToolTipsOn: false`
-- `WindowsLookAndFeel`以外では`InternalFrame.titleButtonToolTipsOn`は設定されておらず`null`になるのでデフォルトは`false`となる
-- `MetalLookAndFeel`や`NimbusLookAndFeel`ではこの設定は無視されて常に`JInternalFrame`のタイトルバーに配置された閉じる、最大化、最小化`JButton`で`JToolTip`は表示される
-- `MotifLookAndFeel`ではこの設定は無視されて常に`JInternalFrame`のタイトルバーに配置された最大化、最小化`JButton`で`JToolTip`は非表示になる

* 参考リンク [#reference]
- [[DesktopPropertyの変更を監視する>Swing/DesktopProperty]]
- [https://docs.oracle.com/javase/jp/8/docs/technotes/guides/swing/1.4/w2k_props.html Windowsデスクトップ関連のプロパティのサポート]

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