I am currently going through the example code found here: http://www.java2s.com/Code/Java/Chart/JFreeChartStackedBarChartDemo1.htm
package org.jfree.chart.demo;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.CategoryDataset;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
/**
* A simple demonstration application showing how to create a stacked bar chart
* using data from a {@link CategoryDataset}.
*
*/
public class StackedBarChartDemo1 extends ApplicationFrame {
/**
* Creates a new demo.
*
* @param title the frame title.
*/
public StackedBarChartDemo1(final String title) {
super(title);
final CategoryDataset dataset = createDataset();
final JFreeChart chart = createChart(dataset);
final ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
setContentPane(chartPanel);
}
/**
* Creates a sample dataset.
*
* @return a sample dataset.
*/
private CategoryDataset createDataset() {
return DemoDatasetFactory.createCategoryDataset();
}
/**
* Creates a sample chart.
*
* @param dataset the dataset for the chart.
*
* @return a sample chart.
*/
private JFreeChart createChart(final CategoryDataset dataset) {
final JFreeChart chart = ChartFactory.createStackedBarChart(
"Stacked Bar Chart Demo 1", // chart title
"Category", // domain axis label
"Value", // range axis label
dataset, // data
PlotOrientation.VERTICAL, // the plot orientation
true, // legend
true, // tooltips
false // urls
);
return chart;
}
public static void main(final String[] args) {
final StackedBarChartDemo1 demo = new StackedBarChartDemo1("Stacked Bar Chart Demo 1");
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true);
}
}
For This part
public StackedBarChartDemo1(final String title) {
super(title);
final CategoryDataset dataset = createDataset();
final JFreeChart chart = createChart(dataset);
final ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
setContentPane(chartPanel);
}
I'm a bit confused with what super(title); does. I know that it calls the parent constructor with the String parameter "tittle" but I'm hoping someone can explain what it does with the parameter. I have looked at numerous tutorials and they have helped but their answer to my question are a little to advanced for me. I understand how super() is used when calling a method from the parent class but I don't see why it is needed in this code. My guess is that it is being passed to the ApplicationFrame class to be put in the method setTitle() but I'm not sure how it works.