Swing/HtmlDisable のバックアップ(No.5)
- バックアップ一覧
- 差分 を表示
- 現在との差分 を表示
- 現在との差分 - Visual を表示
- ソース を表示
- Swing/HtmlDisable へ行く。
- 1 (2008-04-21 (月) 13:43:08)
- 2 (2008-08-08 (金) 12:08:32)
- 3 (2014-10-03 (金) 14:12:15)
- 4 (2015-11-08 (日) 16:16:18)
- 5 (2017-05-09 (火) 17:54:31)
- 6 (2018-04-27 (金) 21:58:23)
- 7 (2020-04-23 (木) 18:41:26)
- 8 (2021-10-28 (木) 03:20:18)
- 9 (2025-01-03 (金) 08:57:02)
- 10 (2025-01-03 (金) 09:01:23)
- 11 (2025-01-03 (金) 09:02:38)
- 12 (2025-01-03 (金) 09:03:21)
- 13 (2025-01-03 (金) 09:04:02)
- category: swing
folder: HtmlDisable
title: JLabelなどのHtmlレンダリングを無効化
tags: [JLabel, Html, JToolTip]
author: aterai
pubdate: 2008-04-21T13:43:08+09:00
description: JLabelなどのHtmlレンダリングを無効化して、タグ文字列をそのまま表示します。
image:
概要
JLabel
などのHtml
レンダリングを無効化して、タグ文字列をそのまま表示します。
Screenshot

Advertisement
サンプルコード
label1.putClientProperty("html.disable", Boolean.TRUE);
label1.setText("<html><font color=red>Html Test</font></html>");
label1.setToolTipText("<html><html><font color=red>Html Test</font></html></html>");
View in GitHub: Java, Kotlin解説
上記のサンプルでは、JLabel
などにputClientProperty("html.disable", Boolean.TRUE)
を設定することで、<html>
タグとしてレンダリングせずにそのまま文字列として表示しています。
JLabel
に、putClientProperty("html.disable", Boolean.TRUE)
としても、その JLabel
のJToolTip
には反映されないので、<html>
タグの中で文字実体参照を使っています。