Kol*_*rie 0 html java swing superscript jbutton
我试图用JBF-8编码将我的JButton的文本设置为"Compute b--¹(mod a)",但这两个尝试都不起作用.问题是减号,但不确定我能做什么.
尝试1:
_computeModInverseButton = new JButton("Compute b?¹ (mod a)");
Run Code Online (Sandbox Code Playgroud)

尝试2:
_computeModInverseButton = new JButton("Compute b<html><sup>-1</sup></html> (mod a)");
Run Code Online (Sandbox Code Playgroud)

所以问题是我的HTML格式,但现在有了
_computeModInverseButton = new JButton("Compute b-1 (mod a)");
Run Code Online (Sandbox Code Playgroud)
看起来像
如何格式化以适应上标?
请参阅https://docs.oracle.com/javase/tutorial/uiswing/components/html.html
要指定组件的文本具有HTML格式,只需将标记放在文本的开头,然后在其余部分中使用任何有效的HTML.以下是在按钮文本中使用HTML的示例:
button = new JButton("<html><b><u>T</u>wo</b><br>lines</html>");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
514 次 |
| 最近记录: |