如何在java中为复选框文本编写上标词? [英] How do I write superscript word for checkbox text in java?

查看:23
本文介绍了如何在java中为复选框文本编写上标词?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Java 中使用 Swing 创建了几个复选框.我想为复选框写一个上标文本,但我不确定如何.

I made few checkboxes using swing in Java. I want to write a superscript text for the checkboxes but I'm not sure how.

当前代码如下所示.

JCheckBox hCheckBox = new JCheckBox("[M + H]+");

我想在 JCheckBox 参数中添加+"号上标.有什么简单的方法可以做到这一点?

I want to have "+" sign inside the JCheckBox parameter superscripted. What's an easy way to do this?

提前致谢.

推荐答案

Java 按钮在其文本中支持 html.不过,您需要稍微不同地格式化字符串.试试这个:

Java buttons support html in their text. You need to format the string a little differently though. Try this:

JCheckBox hCheckBox = new JCheckBox("<html>[M + H]<sup>+</sup></html>"); 

这篇关于如何在java中为复选框文本编写上标词?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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