问题
As of now my legend is displayed like this
test1 5%
test2test2 10%
test2test2test3 85%
I am trying to display like this, with spaces and right aligned.
test1-------------------------5%
test2test2test2-----------10%
test3test3test3-----------85%
Any suggesstions appreciated
回答1:
You can use the approach shown here to create a separate panel containing your legend items. Give the panel a GridLayout(0, 1)
; specify JLabel.LEFT
for the left column and JLabel.RIGHT
for the right column. A complete example is shown here.
来源:https://stackoverflow.com/questions/28507357/aligning-text-in-piechart-legend-how-to-right-align-the-content-inside-the-leg