---
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のタイトルバーに配置された閉じる、最大化、最小化JButtonでJToolTipの表示・非表示を切り替えます。
image: https://drive.google.com/uc?id=1SLM6oYpp38PKBED36pr5cj4VOAeXEq4I
---
* Summary [#summary]
`JInternalFrame`のタイトルバーに配置された閉じる、最大化、最小化`JButton`で`JToolTip`の表示・非表示を切り替えます。
#download(https://drive.google.com/uc?id=1SLM6oYpp38PKBED36pr5cj4VOAeXEq4I)
* Source Code Examples [#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);
});
}}
* Description [#explanation]
* Description [#description]
- `InternalFrame.titleButtonToolTipsOn: true`
-- `WindowsLookAndFeel`のデフォルト
-- `WindowsLookAndFeel.java`で`Object hotTrackingOn = new WindowsDesktopProperty("win.item.hotTrackingOn", true);`と設定されており、`Windows`デスクトップのプロパティ変更と連動している?
-- `hotTrackingOn`はメニューバーのロールオーバーにも使用されている
--- `"InternalFrame.titleButtonToolTipsOn", hotTrackingOn,`
--- `"MenuBar.rolloverEnabled", hotTrackingOn,`
- `InternalFrame.titleButtonToolTipsOn: false`
-- `WindowsLookAndFeel`以外では`InternalFrame.titleButtonToolTipsOn`は設定されておらず`null`になるのでデフォルトは`false`となる
-- `MetalLookAndFeel`や`NimbusLookAndFeel`ではこの設定は無視されて常に`JInternalFrame`のタイトルバーに配置された閉じる、最大化、最小化`JButton`で`JToolTip`は表示される
-- `MotifLookAndFeel`ではこの設定は無視されて常に`JInternalFrame`のタイトルバーに配置された最大化、最小化`JButton`で`JToolTip`は非表示になる
* Reference [#reference]
- [[DesktopPropertyの変更を監視する>Swing/DesktopProperty]]
- [https://docs.oracle.com/javase/jp/8/docs/technotes/guides/swing/1.4/w2k_props.html Windowsデスクトップ関連のプロパティのサポート]
* Comment [#comment]
#comment
#comment