JFreeChart: Set chart size

I am adding a JFreeChart to ChartPanel, and then adding the ChartPanel to a JPanel.
I want to control the size of the chart.

Please let me know how I can do that. If possible, please provide some sample code. Thanks!
dshrenikAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
for_yanConnect With a Mentor Commented:


I think like you do it and any normal Java application,
something like that:

Container c = this.getContentPane();
c.setLayout(new FlowLayout());
myPanel1.add(myButton);
myPanel1.add(myTextField);
etc.
c.add(myPanel1);
c.add(myPanel2);
this.setSize(500,500);
this.setVisible(true);



0
 
for_yanCommented:
ChartPanle extends JPanel - so you should be able to use all those
setSize() which exist for JPanel and JComponent

Howevere in normal applications you normally avoid set size for JPanels - it is better to devise layourt of your
window (JFrame or something) so that your panels have the size you want
0
 
dshrenikAuthor Commented:
set size did not do the trick.

Can you tell how I can set the layout?
0
 
for_yanCommented:
You just need to devise the way you want your elemsnt to sit in your windowand then select appropriate layout
0
All Courses

From novice to tech pro — start learning today.