Here are some sample segment of codes.
I just want to add a point to the XY Graph
every time click the button.
But it won't work!
What is missing?
Could you help me?
class appendingXY extends XYSeriesCollection
{
static int count=1;
public appendingXY(XYSeries series) {
super ( series );
}
public void addNew () {
getSeries(0).add(90.0*i, 10.0);
notifyListeners(new DatasetChangeEvent(this, this));
}
};
... ...
XYDataset xyDataset;
... ...
JButton jb = new JButton("Change" );
jb.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println ("actionPerformed");
((appendingXY)xyDataset).addNew();
}
} );
Please help.
Re: Please help.
Hi Shirley,
Try out the DynamicDataDemo application in the src/com/jrefinery/chart/demo directory in the distribution. It displays a timeseries that has a new value added each time the user clicks a button.
Regards,
Dave Gilbert
Try out the DynamicDataDemo application in the src/com/jrefinery/chart/demo directory in the distribution. It displays a timeseries that has a new value added each time the user clicks a button.
Regards,
Dave Gilbert
Re: Please help.
Thanks Dave.
I just found out the reason of the chart not
updating.
But when should you use the graph as a JLabel?
Shirley
Here is what I did:
***
JLabel lblChart = new JLabel();
lblChart.setHorizontalAlignment(JLabel.CENTER);
lblChart.setVerticalAlignment(JLabel.CENTER);
lblChart.setIcon(new ImageIcon(image));
this.getContentPane().setLayout(new BorderLayout());
this.getContentPane().add(lblChart, BorderLayout.CENTER);
this.setSize(600,400);
this.setVisible(true);
***
The real chart object is not displayed.
I just found out the reason of the chart not
updating.
But when should you use the graph as a JLabel?
Shirley
Here is what I did:
***
JLabel lblChart = new JLabel();
lblChart.setHorizontalAlignment(JLabel.CENTER);
lblChart.setVerticalAlignment(JLabel.CENTER);
lblChart.setIcon(new ImageIcon(image));
this.getContentPane().setLayout(new BorderLayout());
this.getContentPane().add(lblChart, BorderLayout.CENTER);
this.setSize(600,400);
this.setVisible(true);
***
The real chart object is not displayed.