我使用了一個代碼來顯示一個圖。 我想在此圖中插入一個按鈕(顯示詳細信息),我將使用它來呈現關於該圖的一些細節。它是可實現的嗎? 謝謝。在JFreeChart圖中插入一個按鈕
if(jCheckBox3.isSelected()) {
try {
con = getConnection("jdbc:mysql://localhost:3306/base_rapport","root","");
Statement statement = con.createStatement(rs.TYPE_FORWARD_ONLY,rs.CONCUR_READ_ONLY);
String sql3 = "Select Vendor, sum(Rate) as Rate from (select case Vendor when 'NSN' then 'Nokia' else Vendor end as Vendor, Rate from ( Select vendor ,(count(1))*100/(Select count(id_incident)from incident where open_time between '"+jTextField1.getText()+"' and'"+jTextField2.getText()+"' and vendor !='') as Rate from incident where open_time between '"+jTextField1.getText()+"'and'"+jTextField2.getText()+"' and vendor !='' group by upper(vendor)) as x) as y group by vendor";
rs3 = statement.executeQuery(sql3);
DefaultPieDataset pieDataset = new DefaultPieDataset();
while(rs3.next()) {
pieDataset.setValue(rs3.getString("vendor"),rs3.getDouble(2));
}
JFreeChart chart = ChartFactory.createPieChart3D("Disfonctionnement par fournisseurs", pieDataset, true, true, true);
PiePlot3D piePlot3d = (PiePlot3D) chart.getPlot();
piePlot3d.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}={1}"));
fenetre fen3 = new fenetre();
JPanel pnl = new JPanel(new BorderLayout());
fen3.setContentPane(pnl);
fen3.setVisible(true);
fen3.setSize(500, 500);
ChartPanel cPanel1 = new ChartPanel(chart);
pnl.add(cPanel1);
File fichier = new File("C:\\Users\\alaeddine.zammeli.st\\Desktop\\résultat_application\\Répartition par fournisseur de '"+jTextField1.getText()+"' à '"+jTextField2.getText()+"'.png");
try {
ChartUtilities.saveChartAsPNG(fichier, chart, 500, 500);
} catch (IOException e) {
e.printStackTrace();
}
} catch (Exception e) {
JOptionPane.showMessageDialog(this,e);
}
}