Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2011
    India,Tamil Nadu
    Rep Power

    Smile how can i add JChart in JPanel?

    I added two panels (TablePanel & GraphPanel ) in the JFrame.

    But the Graph displays in the full frame.

    I wish the Graph should display only in the Graphpanel.

    May i know how can i add chart in JPanel?

    I downloaded this chart in this link.

    JFreeChart: Bar Chart Demo : Bar Chart**Chart**Java

    Java Code:
    public class SCMGraph extends javax.swing.JFrame {
      // public class SCMGraph extends javax.swing.JPanel{
    //public class SCMGraph extends ApplicationFrame {
         public SCMGraph() {
            final CategoryDataset dataset = createDataset();
            final JFreeChart chart = createChart(dataset);
           Graphpanel=new ChartPanel(chart);
            //final ChartPanel chartPanel = new ChartPanel(chart);
            Graphpanel.setPreferredSize(new Dimension(300, 270));
            //setSize(400, 500);
    Java Code:
     private javax.swing.JPanel Graphpanel;
    With Regards and Respects,
    Last edited by nandhinianand; 08-08-2011 at 02:19 AM.

  2. #2
    Tamasa is offline Member
    Join Date
    Aug 2011
    Rep Power

    Default ChartPanel=new ChartPanel

    Change the (like width, height etc..)

    Java Code:
    Graphpanel=new ChartPanel(chart);
    use this coding
    Java Code:
    ChartPanel=new ChartPanel(chart);

Similar Threads

  1. Adding a jpanel to a customized Jpanel Class
    By trishtren in forum AWT / Swing
    Replies: 7
    Last Post: 04-05-2011, 07:52 PM
  2. Adding Jpanel ontop of another Jpanel
    By Manfizy in forum AWT / Swing
    Replies: 4
    Last Post: 03-05-2011, 11:34 PM
  3. Placing a new JPanel over a paint overriden JPanel
    By Tanshaydar in forum AWT / Swing
    Replies: 4
    Last Post: 12-08-2010, 07:00 PM
  4. Replies: 1
    Last Post: 11-09-2010, 10:28 AM
  5. Replies: 3
    Last Post: 04-21-2009, 12:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts