Aligning text in pieChart legend - How to right al

2019-02-28 17:18发布

问题:

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.

image http://i46.tinypic.com/30273pc.png