Solved

JFreeChart: Set chart size

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
json example 39 130
wordmultiple challenge 12 116
Starting to learn JAVA, 7 59
maven project error 5 47
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
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:

932 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

19 Experts available now in Live!

Get 1:1 Help Now