Java JFreeChart with dynamic data
===

<br />
since hours I am facing some problems with JfreeChart with Java.
In fact , I am retriving data from remote database to make them display in a Panel from my application.<br />
1. The problem: when I get the data, they do not display directly on the panel,,, I have to minimize and maximize the form to make the data being loaded. <br />
2. I need this data to be refreshing every minute. I was thinking about a Timer but I don't really konw how to integrate it.<br />
these are the codes<br />

    import java.io.BufferedReader;
    import java.net.Socket;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.util.List;
    import java.util.ArrayList;
    import javax.swing.JPanel;
    
    public class GetRequest implements Runnable{
    
        public BufferedReader _input = null;
        public Socket clientSocket = null;
        public DrawChart draw;
        public List<Double> values_1, values_2, values_3, values_4;
        public JPanel _panel;
    
        public GetRequest(Socket socket, JPanel panel){
            clientSocket = socket;
            draw = new DrawChart();
            _panel = panel;
            values_1 = new ArrayList<Double>();
            values_2 = new ArrayList<Double>();
            values_3 = new ArrayList<Double>();
        }
    
        @Override
        public void run(){
            while(true){
    
                try{
                    _input = new BufferedReader(new InputStreamReader(clientSocket.getInputStream ()));
                    String line = _input.readLine ();
    
                    String[] clineComat = line.split (",");
                    for(int i = 0 ;i<clineComat.length;i++){
    
                        String[] clineSemiComa_ = clineComat[i].split (";");
                        System.out.println(">"+clineComat[i]);
                        values_1.add (Double.parseDouble (clineSemiComa_[0])+1);
                        values_2.add (Double.parseDouble (clineSemiComa_[1])+1);
                        values_3.add (Double.parseDouble (clineSemiComa_[2]));
                    }
    
                    draw.displayPie (_panel, values_1, values_2, values_3);
                }
                catch(IOException e){e.printStackTrace ();}
            }
        }}

and this is the code of the DrawChart.java

    import  org.jfree.chart.ChartFactory;
    import  org.jfree.chart.ChartPanel;
    import  org.jfree.chart.JFreeChart;
    import  org.jfree.data.general.DefaultPieDataset;
    import javax.swing.JPanel;
    import java.awt.BorderLayout;
    import org.jfree.chart.plot.PlotOrientation;
    import java.awt.Dimension;
    import org.jfree.data.category.DefaultCategoryDataset;
    import org.jfree.data.category.CategoryDataset;
    import java.util.List;
    import java.lang.Float;
    import java.util.Timer;
    import java.util.TimerTask;
    
    public class DrawChart {

        public void displayPie(JPanel jpanel, List<Double> values_1, List<Double> values_2, List<Double> values_3) {
            
            CategoryDataset data = createDataset(values_1, values_2, values_3);
            //create a chart...
            JFreeChart chart=ChartFactory.createBarChart ("", null, null, data, PlotOrientation.VERTICAL, true, true, false);
            chart = ChartFactory.createLineChart ("", null, null, data, PlotOrientation.VERTICAL, true, true, false);
    
            //create and display a frame...
            ChartPanel panel=new ChartPanel(chart);
            panel.setPreferredSize (new Dimension(700,300));
            jpanel.setLayout(new java.awt.BorderLayout());
            jpanel.add (panel, BorderLayout.CENTER);
            jpanel.setVisible(true);
            }
        
        public static CategoryDataset createDataset(List<Double> a, List<Double> b, List<Double> c) {
    
            String series1 = "Series1";
            String series2 = "Series2";
            String series3 = "Series3";
    
            final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    
            if(a.size () != 0 && b.size () != 0 && c.size () != 0 ) {
    
                for(int i=0;i<a.size ();i++) {
                    dataset.addValue(a.get (i), series1, i+1+"");
                }
    
                for(int i=0;i<b.size ();i++) {
                    dataset.addValue(b.get (i), series2, i+1+"");
                }
    
                for(int i=0;i<c.size ();i++) {
                    dataset.addValue(c.get (i), series3, i+1+"");
                }
    
            }
    
            return dataset;
        }
    }

How can I solve this ? Does anyone has done a similar ?
Thanks
