I used a code in order to display a graph. I want to insert a button in this graph (Show details) that i will used in order to present some details about the graph .I tried with this code but an error appear:"cannot add to layout:constraint must be a string" thanks.
if(jCheckBox1.isSelected()){
try{
Statement statement = con.createStatement(rs.TYPE_FORWARD_ONLY,rs.CONCUR_READ_ONLY);
String sql1 = "Select last_updated_by,(count(id_incident) )*100/(Select count(id_incident) from incident where Status like 'Closed' and open_time between '"+date1+"' and '"+date2+"')from incident where Status like 'Closed'and open_time between '"+date1+"' and '"+date2+"' group by last_updated_by";
rs1 = statement.executeQuery(sql1);
DefaultPieDataset pieDataset = new DefaultPieDataset();
while(rs1.next()){
pieDataset.setValue( rs1.getString("last_updated_by"),rs1.getDouble(2));
}
JFreeChart chart = ChartFactory.createPieChart3D("Taux résolution par personne", pieDataset, true, true, true);
PiePlot3D piePlot3d = (PiePlot3D) chart.getPlot();
piePlot3d.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}={1}"));
fenetre fen= new fenetre();
JPanel pnl = new JPanel(new CardLayout());
fen.setContentPane(pnl);
fen.setVisible(true);
fen.setSize(500, 500);
showdetails = new JButton(new AbstractAction("showdetails") {
@Override
public void actionPerformed(ActionEvent e) {
//To change body of generated methods, choose Tools | Templates.
}
}) ;
ChartPanel cPanel1 = new ChartPanel(chart);
pnl.add(cPanel1,showdetails);
File fichier = new File("C:\\Users\\Desktop\\résultat_application\\Taux résolution par personne de '"+date1+"' à '"+date2+"'.png");
try {
ChartUtilities.saveChartAsPNG(fichier, chart, 400, 250);
} catch (IOException e) {
e.printStackTrace();
}
}
catch (Exception e) {
JOptionPane.showMessageDialog(this,e);
}
}