JFreeChart: Set chart size

Posted on 2011-09-27
Last Modified: 2012-05-12
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!
Question by:dshrenik
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
LVL 47

Expert Comment

ID: 36713520
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

Author Comment

ID: 36713526
set size did not do the trick.

Can you tell how I can set the layout?
LVL 47

Accepted Solution

for_yan earned 500 total points
ID: 36713535

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

Container c = this.getContentPane();
c.setLayout(new FlowLayout());

LVL 47

Expert Comment

ID: 36713541
You just need to devise the way you want your elemsnt to sit in your windowand then select appropriate layout

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question