0

我想创建一个包含一些文本的 JLabel。文字后面应该有一个栏。条的宽度应取决于一些外部参数。是否可以通过 JLabels 的基本 HTML 支持来做到这一点?

小样

4

1 回答 1

2

也许,但我不会那样做,我会使用 aJProgressBar创建那个栏,因为它甚至支持在其上绘制的字符串。有关更多详细信息,请参阅此问题

简而言之:

// Do this when initializing:
yourProgressBar.setStringPainted(true);

// When you want to update it:
yourProgressBar.setValue(theCurrentValueAsInt);
yourProgressbar.setString(theCurrentValueAsString); // That can be any string.
于 2013-02-15T15:32:02.467 回答