Solved

JFreeChart: Set chart size

Posted on 2011-09-27
4
732 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 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

760 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now