1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| public class Graphique extends ApplicationFrame implements Runnable {
private static final long serialVersionUID = 1L;
public Graphique(final String title) {
super(title);
graphique();
}
private void graphique(){
try {
Thread t = new Thread(this);
// lancement du thread (méthode run())
t.start();
}catch (Exception e){System.err.println(e);}
}
/** réalisation du graphique **/
public void run(){
// note ::dataset comporte une liste de nombre.
JFreeChart chart = ChartFactory.createHistogram(
"Distribution pertes",
null,
null,
dataset,
PlotOrientation.VERTICAL,
true,
false,
false
);
ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
setContentPane(chartPanel);
}
} |