Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package streaming.swing; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import streaming.entity.Genre; import streaming.entity.Lien; import streaming.entity.Pays; import streaming.entity.Realisateur; import streaming.entity.Saison; import streaming.entity.Serie; import streaming.exeptions.SynopsisVideException; import streaming.service.GenreService; import streaming.service.LienService; import streaming.service.PaysService; import streaming.service.RealisateurService; import streaming.service.SaisonService; import streaming.service.SerieService; /** * * @author admin */ @Component public class JDialogSerie extends javax.swing.JDialog { @Autowired PaysService paysService; @Autowired SaisonService saisonService; @Autowired SerieService serieService; List<Pays> listePays; List<Saison> listeSaison; @Autowired private JPannelListeSerie jpSeries; /** * Creates new form JDialogGenre */ // public JDialogSerie(java.awt.Frame parent, boolean modal, JPannelListeSerie jp) { // super(parent, modal); // initComponents(); //// init(); // jpSeries=jp; // } public JDialogSerie() { this.setModal(true); initComponents(); } public JPannelListeSerie getJpSeries() { return jpSeries; } public void setJpSeries(JPannelListeSerie jpSeries) { this.jpSeries = jpSeries; } public void init() { for (Pays p : listePays) jComboBox1.addItem(p.getNom()); for (Saison r : listeSaison) jComboBoxSaison.addItem(r.getNum_saison().toString()); } /** * 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() { jLabel2 = new javax.swing.JLabel(); jPanel3 = new javax.swing.JPanel(); jTextFieldID = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); jPanel4 = new javax.swing.JPanel(); jTextTitre = new javax.swing.JTextField(); jLabel1 = new javax.swing.JLabel(); jPanel1 = new javax.swing.JPanel(); jComboBox1 = new javax.swing.JComboBox<>(); jLabel4 = new javax.swing.JLabel(); jPanel6 = new javax.swing.JPanel(); jTextSynopsis = new javax.swing.JTextField(); jLabel5 = new javax.swing.JLabel(); jPanel7 = new javax.swing.JPanel(); jComboBoxSaison = new javax.swing.JComboBox<>(); jPanel8 = new javax.swing.JPanel(); jPanel9 = new javax.swing.JPanel(); jBAjouter = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("Genre"); getContentPane().setLayout(new java.awt.GridLayout(6, 3)); jLabel2.setText("ID"); getContentPane().add(jLabel2); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 209, Short.MAX_VALUE)); jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 81, Short.MAX_VALUE)); getContentPane().add(jPanel3); jTextFieldID.setEditable(false); jTextFieldID.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTextFieldIDActionPerformed(evt); } }); getContentPane().add(jTextFieldID); jLabel3.setText("Titre"); getContentPane().add(jLabel3); javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); jPanel4.setLayout(jPanel4Layout); jPanel4Layout.setHorizontalGroup(jPanel4Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 209, Short.MAX_VALUE)); jPanel4Layout.setVerticalGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 81, Short.MAX_VALUE)); getContentPane().add(jPanel4); jTextTitre.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTextTitreActionPerformed(evt); } }); getContentPane().add(jTextTitre); jLabel1.setText("Pays"); getContentPane().add(jLabel1); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 209, Short.MAX_VALUE)); jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 81, Short.MAX_VALUE)); getContentPane().add(jPanel1); jComboBox1.setModel( new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); jComboBox1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jComboBox1ActionPerformed(evt); } }); getContentPane().add(jComboBox1); jLabel4.setText("Synopsis"); getContentPane().add(jLabel4); javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6); jPanel6.setLayout(jPanel6Layout); jPanel6Layout.setHorizontalGroup(jPanel6Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 209, Short.MAX_VALUE)); jPanel6Layout.setVerticalGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 81, Short.MAX_VALUE)); getContentPane().add(jPanel6); jTextSynopsis.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jTextSynopsisActionPerformed(evt); } }); getContentPane().add(jTextSynopsis); jLabel5.setText("Saison"); getContentPane().add(jLabel5); javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7); jPanel7.setLayout(jPanel7Layout); jPanel7Layout.setHorizontalGroup(jPanel7Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 209, Short.MAX_VALUE)); jPanel7Layout.setVerticalGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 81, Short.MAX_VALUE)); getContentPane().add(jPanel7); jComboBoxSaison.setModel( new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); jComboBoxSaison.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jComboBoxSaisonActionPerformed(evt); } }); getContentPane().add(jComboBoxSaison); javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8); jPanel8.setLayout(jPanel8Layout); jPanel8Layout.setHorizontalGroup(jPanel8Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 209, Short.MAX_VALUE)); jPanel8Layout.setVerticalGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 81, Short.MAX_VALUE)); getContentPane().add(jPanel8); javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9); jPanel9.setLayout(jPanel9Layout); jPanel9Layout.setHorizontalGroup(jPanel9Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 209, Short.MAX_VALUE)); jPanel9Layout.setVerticalGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 81, Short.MAX_VALUE)); getContentPane().add(jPanel9); jBAjouter.setText("Ajouter"); jBAjouter.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jBAjouterActionPerformed(evt); } }); getContentPane().add(jBAjouter); pack(); }// </editor-fold>//GEN-END:initComponents private void jTextTitreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextTitreActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jTextTitreActionPerformed private void jTextFieldIDActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldIDActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jTextFieldIDActionPerformed private void jTextSynopsisActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextSynopsisActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jTextSynopsisActionPerformed private void jBAjouterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBAjouterActionPerformed int indSaison = jComboBoxSaison.getSelectedIndex(); int indPays = jComboBox1.getSelectedIndex(); Serie r = new Serie(null, jTextTitre.getText(), jTextSynopsis.getText()); r.setSaisons((List<Saison>) saisonService.recheSaison(indSaison)); r.setPays(paysService.recherchePays(indPays)); try { serieService.ajouter(r); } catch (SynopsisVideException ex) { Logger.getLogger(JDialogSerie.class.getName()).log(Level.SEVERE, null, ex); } this.jpSeries.rafraichirJTable(); this.setVisible(false); }//GEN-LAST:event_jBAjouterActionPerformed private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jComboBox1ActionPerformed private void jComboBoxSaisonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxSaisonActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jComboBoxSaisonActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jBAjouter; private javax.swing.JComboBox<String> jComboBox1; private javax.swing.JComboBox<String> jComboBoxSaison; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel3; private javax.swing.JPanel jPanel4; private javax.swing.JPanel jPanel6; private javax.swing.JPanel jPanel7; private javax.swing.JPanel jPanel8; private javax.swing.JPanel jPanel9; private javax.swing.JTextField jTextFieldID; private javax.swing.JTextField jTextSynopsis; private javax.swing.JTextField jTextTitre; // End of variables declaration//GEN-END:variables }