Solved

JFreeChart: Set chart size

Posted on 2011-09-27
4
990 Views
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!
0
Comment
Question by:dshrenik
[X]
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
4 Comments
 
LVL 47

Expert Comment

by:for_yan
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
0
 

Author Comment

by:dshrenik
ID: 36713526
set size did not do the trick.

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

Accepted Solution

by:
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());
myPanel1.add(myButton);
myPanel1.add(myTextField);
etc.
c.add(myPanel1);
c.add(myPanel2);
this.setSize(500,500);
this.setVisible(true);



0
 
LVL 47

Expert Comment

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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

615 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