---
category: swing
folder: ToolTipBorder
title: JToolTipにBorderを設定
tags: [JToolTip, Border, MatteBorder, JComponent]
author: aterai
pubdate: 2005-08-15T00:22:53+09:00
description: JComponentのcreateToolTip()メソッドをオーバーライドして、Borderを変更したJToolTipを生成します。
image: https://lh6.googleusercontent.com/_9Z4BYR88imo/TQTVjcQsX6I/AAAAAAAAAn0/tieki8bniAM/s800/ToolTipBorder.png
---
* Summary [#summary]
`JComponent`の`createToolTip()`メソッドをオーバーライドして、`Border`を変更した`JToolTip`を生成します。
#download(https://lh6.googleusercontent.com/_9Z4BYR88imo/TQTVjcQsX6I/AAAAAAAAAn0/tieki8bniAM/s800/ToolTipBorder.png)
* Source Code Examples [#sourcecode]
#code(link){{
JButton button = new JButton() {
@Override public JToolTip createToolTip() {
JToolTip tip = new JToolTip();
Border b1 = tip.getBorder();
Border b2 = BorderFactory.createMatteBorder(0, 10, 0, 0, Color.GREEN);
tip.setBorder(BorderFactory.createCompoundBorder(b1, b2));
tip.setComponent(this);
return tip;
}
};
button.setToolTipText("Test - ToolTipText1");
}}
* Description [#explanation]
* Description [#description]
上記のサンプルでは、`JComponent#createToolTip()`メソッドをオーバーライドして`JToolTip`のデフォルト`Border`と`MatteBorder`を組み合わせた`Border`を設定しています。
* Reference [#reference]
- [https://docs.oracle.com/javase/jp/8/docs/api/javax/swing/JComponent.html#createToolTip-- JComponent#createToolTip() (Java Platform SE 8)]
* Comment [#comment]
#comment
#comment