加下划线的JLabel [英] Underlined JLabel

查看:172
本文介绍了加下划线的JLabel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使JLabel加下划线。我到处搜索,但我一无所获。即使在属性中,也没有选项来强调JLabel。我该怎么办?

I am trying to make a JLabel underlined. I searched everywhere, but I got nothing. Even in the properties, there is no option for underlining the JLabel. What can I do?

推荐答案

JLabel label = new JLabel("<HTML><U>YOUR TEXT HERE</U></HTML>");
label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

OR

JLabel label = new JLabel("Underlined Label");
Font font = label.getFont();
Map attributes = font.getAttributes();
attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
label.setFont(font.deriveFont(attributes));

这篇关于加下划线的JLabel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆