I’m using a program which is based on JAVA. This program is called Anylogic 7. As Anylogic has a poor functionality charts components, I add JFreeChart. My problem, is that I cannot understand, how I can put it on my application window.
I want it to be displayed as this one:
1 If I write such JAVA code, and it adds chart to the New window (but I need to add it to my Main window behind)
Java Code:
Code: Select all
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
String series1 = "Java";
dataset.addValue(5.0, series1, "2005");
dataset.addValue(8.0, series1, "2006");
dataset.addValue(11.0, series1, "2007");
dataset.addValue(15.0, series1, "2008");
//
JFreeChart chart = ChartFactory.createLineChart("A", "B", "C", dataset);
//
JFrame frame = new JFrame("MinimalStaticChart");
frame.add(new ChartPanel(chart));
frame.setSize(400, 300);
frame.show();
2 Then I try to add it to Jframe of my Main window. As you can see on the image, new diagram is add, but it add to the “back” of my presentation window, and it occupies the entire area of the window!!
Code: Select all
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
String series1 = "Java";
dataset.addValue(5.0, series1, "2005");
dataset.addValue(8.0, series1, "2006");
dataset.addValue(11.0, series1, "2007");
dataset.addValue(15.0, series1, "2008");
//
JFreeChart chart = ChartFactory.createLineChart("A", "B", "C", dataset);
getPresentation().getFrame().add(new ChartPanel(chart));
As I understand this task should be similar to the simple addition of new chart in a certain place of the web page.
How can I add it correctly??? What JAVA code I need to write?
Thanks!