How do I update a jPanel wth a Jfreechart

Posted on 2009-02-22
Last Modified: 2013-12-14
I'm trying to create a data file viewer with an application I'm writing. It works the first time, but if you try to press the button again and change the source file and view another data file, it processes it but does not change the graph. Suggestions?
private void jButtonSelectFileActionPerformed(java.awt.event.ActionEvent evt) {                                                  

        // TODO add your handling code here:

        if (txtChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {

            File f = txtChooser.getSelectedFile();



            dataStoragePath = f.getParent();


            final XYDataset dataset = createDataset(configSettings.getDataStoragePath()


            final JFreeChart chart = createChart(dataset);

            ChartPanel panel = new ChartPanel(chart);








Open in new window

Question by:PmiDeveloper
    1 Comment
    LVL 92

    Accepted Solution

    u need to first remove the old one, and call revalidate()



    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
    Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
    The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
    The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now