user3239711
user3239711

Reputation: 649

JfreeChart not displaying before a click

I have built an display a TabPanel. At this stage no Chart is displayed .When I click on a button, I build a new chart an add it to the panel. But nothing happens. I have to click on the panel to have the chart displayed at last.

So I put a repaint() on the TabPanel which contains the ChartPanel but with no effect. Am I missing something here ?

        if(myChart==null){
            myChart = new PortfolioChart(portfolioModel.getDataMatrix());
            add(myChart.createPanel(), BorderLayout.CENTER);
            repaint();
        }else{
            myChart.setPortfolio(portfolioModel.getDataMatrix());
            myChart.updateDataSet();

        }   

May be I should put the repaint() instruction on something differrent ?

Upvotes: 1

Views: 233

Answers (1)

trashgod
trashgod

Reputation: 205765

In the complete example shown here, each tab has a ChartPanel. Rather than replacing the chart, each chart's data model is updated periodically, and the listening chart repaints itself in response.

image

Upvotes: 1

Related Questions