Java tutorial
/* * Copyright (C) 2014 omar * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package tn.mariages.gui; import java.awt.Dimension; import java.awt.Toolkit; import java.awt.image.BufferedImage; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.util.HashMap; import java.util.Iterator; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.UIManager; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.CategoryLabelPositions; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.renderer.category.CategoryItemRenderer; import org.jfree.data.category.CategoryDataset; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.data.general.DefaultPieDataset; import org.jfree.ui.ApplicationFrame; import org.jfree.ui.RefineryUtilities; import tn.mariages.dao.CommentaireDAO; import tn.mariages.dao.ProduitDAO; import tn.mariages.dao.panierProduitDAO; import tn.mariages.entities.PanierProduit; import tn.mariages.entities.Produit; /** * * @author omar */ public class Accueil extends javax.swing.JFrame { /** * Creates new form Accueil */ public Accueil() { try { org.jb2011.lnf.beautyeye.BeautyEyeLNFHelper.launchBeautyEyeLNF(); UIManager.put("RootPane.setupButtonVisible", false); } catch (Exception e) { //TODO exception } initComponents(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jTextField1 = new javax.swing.JTextField(); jPanel1 = new javax.swing.JPanel(); jPanel2 = new javax.swing.JPanel(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); jButton4 = new javax.swing.JButton(); jButton5 = new javax.swing.JButton(); jButton6 = new javax.swing.JButton(); jButton7 = new javax.swing.JButton(); jbtnRec = new javax.swing.JButton(); jTextField1.setText("jTextField1"); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); addWindowListener(new java.awt.event.WindowAdapter() { public void windowOpened(java.awt.event.WindowEvent evt) { formWindowOpened(evt); } }); jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder()); jPanel1.setName("GoldenCage"); // NOI18N jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/icons/heart.png"))); // NOI18N jButton1.setToolTipText("Favoris"); jButton1.setMaximumSize(new java.awt.Dimension(40, 40)); jButton1.setMinimumSize(new java.awt.Dimension(40, 40)); jButton1.setPreferredSize(new java.awt.Dimension(40, 40)); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/icons/user.png"))); // NOI18N jButton2.setToolTipText("Utilisateurs"); jButton2.setMaximumSize(new java.awt.Dimension(40, 40)); jButton2.setMinimumSize(new java.awt.Dimension(40, 40)); jButton2.setPreferredSize(new java.awt.Dimension(40, 40)); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/icons/users.png"))); // NOI18N jButton3.setToolTipText("Prestataires"); jButton3.setMaximumSize(new java.awt.Dimension(40, 40)); jButton3.setMinimumSize(new java.awt.Dimension(40, 40)); jButton3.setPreferredSize(new java.awt.Dimension(40, 40)); jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } }); jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/icons/shopping_cart.png"))); // NOI18N jButton4.setToolTipText("Produits"); jButton4.setMaximumSize(new java.awt.Dimension(40, 40)); jButton4.setMinimumSize(new java.awt.Dimension(40, 40)); jButton4.setPreferredSize(new java.awt.Dimension(40, 40)); jButton4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton4ActionPerformed(evt); } }); jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/icons/basket.png"))); // NOI18N jButton5.setToolTipText("Paquets"); jButton5.setMaximumSize(new java.awt.Dimension(40, 40)); jButton5.setMinimumSize(new java.awt.Dimension(40, 40)); jButton5.setPreferredSize(new java.awt.Dimension(40, 40)); jButton5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton5ActionPerformed(evt); } }); jButton6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/icons/chart_pie.png"))); // NOI18N jButton6.setToolTipText("Statistiques"); jButton6.setMaximumSize(new java.awt.Dimension(40, 40)); jButton6.setMinimumSize(new java.awt.Dimension(40, 40)); jButton6.setPreferredSize(new java.awt.Dimension(40, 40)); jButton6.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton6ActionPerformed(evt); } }); jButton7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/icons/user_circle.png"))); // NOI18N jButton7.setToolTipText("Administration"); jButton7.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton7ActionPerformed(evt); } }); jbtnRec.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/icons/warning.png"))); // NOI18N jbtnRec.setToolTipText("Rclamations"); jbtnRec.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jbtnRecActionPerformed(evt); } }); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup(jPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap().addGroup(jPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) .addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jbtnRec, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(20, Short.MAX_VALUE))); jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup().addGap(0, 15, Short.MAX_VALUE) .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jbtnRec, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(9, 9, 9))); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE).addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup( javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addGap(0, 0, 0).addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); pack(); }// </editor-fold>//GEN-END:initComponents private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened int h = Toolkit.getDefaultToolkit().getScreenSize().height; int w = Toolkit.getDefaultToolkit().getScreenSize().width; Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); this.setLocation(-27, -16); this.setSize(144, h + 16); this.setExtendedState(this.MAXIMIZED_VERT); System.out.println("H " + h); JFrame LogoFrame = new JFrame("Logo"); LogoFrame.setSize(w - 45, h + 16); LogoFrame.setExtendedState(this.MAXIMIZED_HORIZ); this.setAlwaysOnTop(true); //LogoFrame.setExtendedState(LogoFrame.MAXIMIZED_BOTH); LogoFrame.setLocation(65, -16); JPanel logoPanel = new JPanel(); LogoFrame.add(logoPanel); ImageIcon icon; try { icon = new ImageIcon(new URL("http://www.images.tn/upload/original/1394208853.png")); /// TO CHANGE icon = new ImageIcon(icon.getImage().getScaledInstance(400, 400, BufferedImage.SCALE_SMOOTH)); JLabel logoLabel = new JLabel(icon); logoPanel.add(logoLabel); logoLabel.setAlignmentX(CENTER_ALIGNMENT); logoLabel.setAlignmentY(400); } catch (MalformedURLException ex) { Logger.getLogger(ListeFeatProd.class.getName()).log(Level.SEVERE, null, ex); } LogoFrame.setVisible(true); // TODO add your handling code here: }//GEN-LAST:event_formWindowOpened private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); ListePrestataire LPrs = new ListePrestataire(); LPrs.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); LPrs.setLocationRelativeTo(null); LPrs.setVisible(true); }//GEN-LAST:event_jButton3ActionPerformed private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed ListeFeatProd LFP = new ListeFeatProd(); Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); LFP.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); LFP.setLocationRelativeTo(null); LFP.setVisible(true); }//GEN-LAST:event_jButton1ActionPerformed private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed //<editor-fold defaultstate="collapsed" desc="Bar Chart"> BarChart demo; try { demo = new BarChart("Ventes par mois"); demo.pack(); RefineryUtilities.centerFrameOnScreen(demo); demo.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); demo.setSize(700, 350); demo.setVisible(true); } catch (IOException ex) { Logger.getLogger(Accueil.class.getName()).log(Level.SEVERE, null, ex); } // </editor-fold> // <editor-fold defaultstate="collapsed" desc="Stat Ventes Prod"> StatVentesProd pchart = new StatVentesProd(); pchart.setLocation(200, 300); pchart.setSize(400, 400); pchart.setVisible(true); // </editor-fold> PieChartComs pchartc; pchartc = new PieChartComs(); pchartc.setSize(400, 400); pchartc.setLocation(600, 300); pchartc.setVisible(true); }//GEN-LAST:event_jButton6ActionPerformed private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); ListeClients LC = new ListeClients(); LC.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); LC.setLocationRelativeTo(null); LC.setVisible(true); }//GEN-LAST:event_jButton2ActionPerformed private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); ListerProduit LP = new ListerProduit(); LP.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); LP.setLocationRelativeTo(null); LP.setVisible(true); }//GEN-LAST:event_jButton4ActionPerformed private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); ListePaquets LP = new ListePaquets(); LP.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); LP.setLocationRelativeTo(null); LP.setVisible(true); }//GEN-LAST:event_jButton5ActionPerformed private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed ListeAdmins LA = new ListeAdmins(); Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); LA.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); LA.setLocationRelativeTo(null); LA.setVisible(true); }//GEN-LAST:event_jButton7ActionPerformed private void jbtnRecActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnRecActionPerformed Reclamations rec = new Reclamations(); rec.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); rec.setLocationRelativeTo(null); rec.setVisible(true); }//GEN-LAST:event_jbtnRecActionPerformed /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } // javax.swing.UIManager.setLookAndFeel(WebLookAndFeel.class.getCanonicalName()); } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(AjoutProduit.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(AjoutProduit.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(AjoutProduit.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(AjoutProduit.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> try { org.jb2011.lnf.beautyeye.BeautyEyeLNFHelper.launchBeautyEyeLNF(); UIManager.put("RootPane.setupButtonVisible", false); } catch (Exception e) { //TODO exception } /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { Accueil ac = new Accueil(); int h = Toolkit.getDefaultToolkit().getScreenSize().height; int w = Toolkit.getDefaultToolkit().getScreenSize().width; ac.setLocation(0, 0); ac.setSize(144, h + 16); ac.setExtendedState(ac.MAXIMIZED_HORIZ); ac.setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JButton jButton4; private javax.swing.JButton jButton5; private javax.swing.JButton jButton6; private javax.swing.JButton jButton7; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JTextField jTextField1; private javax.swing.JButton jbtnRec; // End of variables declaration//GEN-END:variables } // <editor-fold defaultstate="collapsed" desc=" BarChart Class"> class BarChart extends JFrame { public BarChart(final String title) throws IOException { super(title); final CategoryDataset dataset = createDataset(); final JFreeChart graphe = createChart(dataset); final ChartPanel chartPanel = new ChartPanel(graphe); chartPanel.setPreferredSize(new java.awt.Dimension(400, 400)); setContentPane(chartPanel); } public CategoryDataset createDataset() throws IOException { // 0. Cration d'un diagramme. DefaultCategoryDataset dataset = new DefaultCategoryDataset(); //Valeurs statiques panierProduitDAO ppDAO = new panierProduitDAO(); int[] sellsByMonth = ppDAO.getSellsByMonth(); String mois; for (int i = 0; i < 12; i++) { switch (i) { case 0: mois = "Janvier"; break; case 1: mois = "Fvrier"; break; case 2: mois = "Mars"; break; case 3: mois = "Avril"; break; case 4: mois = "Mai"; break; case 5: mois = "Juin"; break; case 6: mois = "Juillet"; break; case 7: mois = "Aot"; break; case 8: mois = "Septembre"; break; case 9: mois = "Octobre"; break; case 10: mois = "Novembre"; break; case 11: mois = "Dcembre"; break; default: mois = ""; } dataset.addValue(sellsByMonth[i], mois, " "); } /* dataset.addValue(10, "Taux de dfaut de couverture", " "); dataset.addValue(12, " Taux de couverture Outdoor", " "); dataset.addValue(25, "Taux de couverture Indoor", " "); dataset.addValue(19, "Taux de couverture Incar", " ");*/ return dataset; } public JFreeChart createChart(CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createBarChart(" Ventes par mois ", // chart title " ", // domain axis label " Le nombre de produit ", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips true // urls ); final CategoryPlot plot = chart.getCategoryPlot(); final CategoryAxis axis = plot.getDomainAxis(); axis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2.0)); final CategoryItemRenderer renderer = plot.getRenderer(); renderer.setItemLabelsVisible(true); return chart; } } // </editor-fold> // <editor-fold defaultstate="collapsed" desc="Stat ventes prod"> class StatVentesProd extends JFrame { DefaultPieDataset dataset;//Dataset qui va contenir les Donnes JFreeChart graphe; //Graphe ChartPanel cp; //Panel public StatVentesProd() { dataset = new DefaultPieDataset(); panierProduitDAO ppDAO = new panierProduitDAO(); PanierProduit pp = new PanierProduit(); HashMap<Integer, Integer> top10BestSeller = ppDAO.getTop10BestSeller(); ProduitDAO pDAO = new ProduitDAO(); Iterator<Integer> i = top10BestSeller.keySet().iterator(); while (i.hasNext()) { Integer key = i.next(); System.out.println("key: " + key + " value: " + top10BestSeller.get(key)); Produit DisplayProdByID = pDAO.DisplayProdByID(key); dataset.setValue("" + DisplayProdByID.getNomProd(), new Double(top10BestSeller.get(key))); } graphe = ChartFactory.createPieChart("Top Ventes Produits", dataset); cp = new ChartPanel(graphe); this.add(cp); } } // </editor-fold> // <editor-fold defaultstate="collapsed" desc="Top Coms"> @SuppressWarnings("serial") class PieChartComs extends JFrame { DefaultPieDataset dataset;//Dataset qui va contenir les Donnes JFreeChart graphe; //Graphe ChartPanel cp; //Panel public PieChartComs() { dataset = new DefaultPieDataset(); CommentaireDAO cDAO = new CommentaireDAO(); HashMap<Integer, Integer> top10Coms = cDAO.getTop10Coms(); Produit p = new Produit(); ProduitDAO pDAO = new ProduitDAO(); Iterator<Integer> i = top10Coms.keySet().iterator(); while (i.hasNext()) { Integer key = i.next(); System.out.println("key: " + key + " value: " + top10Coms.get(key)); Produit DisplayProdByID = pDAO.DisplayProdByID(key); dataset.setValue("" + DisplayProdByID.getNomProd(), new Double(top10Coms.get(key))); System.out.println("1"); } graphe = ChartFactory.createPieChart("Top Commentaires", dataset); cp = new ChartPanel(graphe); this.add(cp); } } // </editor-fold>