Results 1 to 8 of 8
  1. #1
    sathya11491 is offline Member
    Join Date
    Mar 2012
    Posts
    12
    Rep Power
    0

    Default jfreechart and jpanel

    hello guys

    Iam using netbeans platform for developing my application.

    I have a jpanel and i have a piechart created using jfreechart .

    but the following code doesnt work

    ChartPanel piechart = new ChartPanel(chart);
    jpanel.add(piechart);

    after execution,the jpanel is empty...

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: jfreechart and jpanel

    That's not enough information to offer any targeted advice. Maybe you need to understand how layout managers work; go through this Lesson: Laying Out Components Within a Container (The Java™ Tutorials > Creating a GUI With JFC/Swing)

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    sathya11491 is offline Member
    Join Date
    Mar 2012
    Posts
    12
    Rep Power
    0

    Default Re: jfreechart and jpanel

    hi db

    plz see the screen shot below:

    jfreechart and jpanel-jpanel.png

    the green area is the jpanel. iam using the matisse builder(netbeans platform) to develop the gui.
    i have a pie chart created using jfreechart

    i need to display the chart inside the panel.

    after creating the piechart , i did the following

    ChartPanel piechart=new ChartPanel(chart); //chart is the piechart with required values
    jpanel.add(piechart);

    but after executing,i dont see the chart but only the panel

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: jfreechart and jpanel

    So, have you gone through the layout tutorial?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    sathya11491 is offline Member
    Join Date
    Mar 2012
    Posts
    12
    Rep Power
    0

    Default Re: jfreechart and jpanel

    db,

    i went through the tutorial specifically, swings with the netbeans part...
    i came across these codes:

    JPanel contentPane = new JPanel(new BorderLayout());
    contentPane.setBorder(someBorder);
    contentPane.add(someComponent, BorderLayout.CENTER);
    contentPane.add(anotherComponent, BorderLayout.PAGE_END);


    topLevelContainer.setContentPane(contentPane);

    The following question may be absurd for you but i cant get hold of it:
    the topLevelContainer is either jFrame/jDialog/jApplet, but with refernce to the above pic(attached in my previous reply),which is the toplevelcontainer? with reference to which object iam supposed to use setContentpane() menthod?
    please once again remember iam using netbeans platform.

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: jfreechart and jpanel

    If you find the visual designer too difficult to use (no shame in that, it's an advanced tool, not meant for beginners, regardless of what Oracle would have you believe) it's not difficult to learn to write Swing code by hand. You'll find ample guidance in the other sections of the tutorial I gqave you a link for.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  7. #7
    sathya11491 is offline Member
    Join Date
    Mar 2012
    Posts
    12
    Rep Power
    0

    Default Re: jfreechart and jpanel

    db,

    i found a way around it. i just copied the generated code for another component and refactored it to match my chart component.
    here is the code: i have commented out the changed code.....

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
    jPanel1Layout.createParallelGroup(javax.swing.Grou pLayout.Alignment.LEADING)
    .addGroup(jPanel1Layout.createSequentialGroup()
    .addGap(99, 99, 99)
    .addComponent(jButton1)// .addComponent(chart)
    .addContainerGap(146, Short.MAX_VALUE))
    );
    jPanel1Layout.setVerticalGroup(
    jPanel1Layout.createParallelGroup(javax.swing.Grou pLayout.Alignment.LEADING)
    .addGroup(jPanel1Layout.createSequentialGroup()
    .addGap(69, 69, 69)
    .addComponent(jButton1)//.addComponent(chart)
    .addContainerGap(113, Short.MAX_VALUE))
    );

  8. #8
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: jfreechart and jpanel

    Look around the forum FAQs and discover how to post code so that it retains its formatting.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. JFreeChart 1.0.14
    By java software in forum Java Software
    Replies: 1
    Last Post: 08-10-2012, 07:46 AM
  2. Jfreechart
    By aaruviswa in forum Web Frameworks
    Replies: 2
    Last Post: 03-17-2011, 06:51 AM
  3. How to add jfreechart to jPanel?
    By Ypsilon IV in forum AWT / Swing
    Replies: 2
    Last Post: 12-07-2010, 06:52 AM
  4. Replies: 5
    Last Post: 02-25-2009, 08:01 AM
  5. JFreeChart 1.0.5
    By levent in forum Java Software
    Replies: 0
    Last Post: 05-10-2007, 05:36 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
  •