使用paintImmediately()方法时JLabel没有显示完整的字符串?

问题描述 投票:0回答:1

这是用于在JLabel上设置文本的代码段。

使用paintImmediately()方法设置标签时,它不会正确显示字符串:

label.setText("Processing");
label.paintImmediately(testResultLabel.getVisibleRect());
currentTestStatusLabel.paintImmediately(currentTestStatusLabel.getVisibleRect());

这是输出:

enter image description here

java swing jlabel
1个回答
0
投票

找到了截至目前的解决方案:

label.setText("<html>"+someText+"</html>");

© www.soinside.com 2019 - 2024. All rights reserved.