1

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

Alex K
  • 22,315
  • 19
  • 108
  • 236
testuser
  • 668
  • 10
  • 23

1 Answers1

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

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • @trashgod..thank you so much for response. I am creating a required legend panel in separate function, how do I use this new panel as the legend? – testuser Feb 16 '15 at 01:02
  • The `createLegendPanel()` method creates a panel that you can add to your layout. – trashgod Feb 16 '15 at 11:05
  • I am not creating chart through code, I designed a reprot using ireport and using customizer class to modify the legend. I am overridng the method public void customize(JFreeChart chart, JRChart jasperChart) to modify the legend, I am not sure how to assign the legendpanel in this method. – testuser Feb 16 '15 at 15:35
  • Please update your question & tags to reflect this requirement; someone with [tag:iReport] experience may respond.. – trashgod Feb 16 '15 at 19:36