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

    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() {
    
    
            initComponents();
            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);
            //setVisible(true);
            setContentPane(Graphpanel);
    Java Code:
     private javax.swing.JPanel Graphpanel;
    With Regards and Respects,
    Nandhini.
    Last edited by nandhinianand; 08-08-2011 at 01:19 AM.

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

    Default ChartPanel=new ChartPanel

    Change the ChartPanel.java (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, 06:52 PM
  2. Adding Jpanel ontop of another Jpanel
    By Manfizy in forum AWT / Swing
    Replies: 4
    Last Post: 03-05-2011, 10: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, 06:00 PM
  4. Replies: 1
    Last Post: 11-09-2010, 09:28 AM
  5. Replies: 3
    Last Post: 04-20-2009, 11:31 PM

Posting Permissions

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