Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

JFreeChart: Set chart size

Posted on 2011-09-27
4
Medium Priority
?
1,123 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
  • 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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

876 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