cannot add chartpanel to jpanel?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
lengrexin
Posts: 8
Joined: Mon Dec 31, 2007 8:13 pm

cannot add chartpanel to jpanel?

Post by lengrexin » Thu Aug 21, 2008 4:54 am

I want to display multiple charts on one page. I am using a JPanel with GridBagLayout.

Is it possible to display multiple charts per page?
Can I add multiple ChartPanel(s) in a JPanel?

Thanks.

kbng11
Posts: 11
Joined: Wed Aug 20, 2008 8:49 am
Location: Kuala Lumpur, Malaysia

Post by kbng11 » Thu Aug 21, 2008 9:29 am

ChartPanel itself is a extension of JPanel.
Just treat it as a JPanel :wink:

Code: Select all

public class Test extends JFrame
{
      Test()
      {
           .....
           ChartPanel panel1 = new ChartPanel(chart1);
           ChartPanel panel2 = new ChartPanel(chart2);
           panel1.setSize(400, 400);
           panel2.setSize(400, 400);
           add(panel1);
           add(panel2);
           pack();
           setVisible(true);
       }
}
Strafing for excellence

Locked