1

I'm going to add a JTable embedded into a JScrollPane into a ChartPanel of JFreeChart, in order to have it on printed version of chart.

Anyway, by using

chartPanel = new ChartPanel(chart);
chartPanel.setLayout(new BorderLayout(0, 10));
chartPanel.add(dataScrollPane,BorderLayout.SOUTH);

or other form of Layout Managers, the table rendered above the plot:

preview


Is there an efficient way to solve this and show the JScrollPane under the chart in the print prefectly?

amirre
  • 21
  • 5
  • 1
    Is an answer involving a non-JFreeChart panel an option for you? I'd create a JPanel with BorderLayout, add the ChartPanel at BorderLayout.CENTER and your table BorderLayout.SOUTH. – TT. Nov 24 '19 at 09:17
  • I have to agree; while a `ChartPanel` _is a_ `JPanel`, it ignores layout internally. Why can't you print an enclosing panel, as @TT. suggests? – trashgod Nov 24 '19 at 11:45
  • I have done the solution that TT suggested before, but i try to do this without enclosing panel due to better quality of charts in print function of JFreeChart. – amirre Nov 24 '19 at 12:00
  • 1
    I'm not sure why the quality is inadequate in your case, but you can change your chart's default size like [this](https://stackoverflow.com/a/10277372/230513). – trashgod Nov 24 '19 at 12:30

0 Answers0