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.gui; import javax.swing.ComboBoxModel; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import streaming.entity.Serie; import streaming.service.SerieService; /** * * @author admin */ @Component public class SerieJDialogLayout extends javax.swing.JDialog { @Autowired private SerieService serieService; @Autowired private SerieJPanelList jPListeSerie; @Autowired private PaysComboBoxModel paysComboBoxModel; /** * Creates new form SerieJDialogLayout */ public SerieJPanelList getjPListeSerie() { return jPListeSerie; } public void setjPListeSerie(SerieJPanelList jPListeSerie) { this.jPListeSerie = jPListeSerie; } public SerieJDialogLayout() { this.setModal(true); initComponents(); } public void rafraichirJComboBox() { paysComboBoxModel.setPays(); jCSerie.setModel(paysComboBoxModel); jCSerie.repaint(); } /** * 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() { jLabel1 = new javax.swing.JLabel(); jPanel1 = new javax.swing.JPanel(); jTTitre = new javax.swing.JTextField(); jLabel2 = new javax.swing.JLabel(); jPanel2 = new javax.swing.JPanel(); jTSynopsis = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); jPanel6 = new javax.swing.JPanel(); jPanel3 = new javax.swing.JPanel(); jCSerie = new javax.swing.JComboBox<>(); jPanel4 = new javax.swing.JPanel(); jPanel5 = new javax.swing.JPanel(); jPanel7 = new javax.swing.JPanel(); jBValider = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("Nouvelle srie"); getContentPane().setLayout(new java.awt.GridLayout(4, 3)); jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel1.setText("Titre"); jLabel1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); 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, 133, Short.MAX_VALUE)); jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 75, Short.MAX_VALUE)); getContentPane().add(jPanel1); getContentPane().add(jTTitre); jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel2.setText("Synopsis"); jLabel2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); getContentPane().add(jLabel2); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup(jPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 133, Short.MAX_VALUE)); jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 75, Short.MAX_VALUE)); getContentPane().add(jPanel2); getContentPane().add(jTSynopsis); jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel3.setText("Pays"); getContentPane().add(jLabel3); javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6); jPanel6.setLayout(jPanel6Layout); jPanel6Layout.setHorizontalGroup(jPanel6Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 133, Short.MAX_VALUE)); jPanel6Layout.setVerticalGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 75, Short.MAX_VALUE)); getContentPane().add(jPanel6); jCSerie.setModel( new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); jCSerie.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jCSerieActionPerformed(evt); } }); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout .setHorizontalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup().addGap(27, 27, 27) .addComponent(jCSerie, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(33, Short.MAX_VALUE))); jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup() .addContainerGap(29, Short.MAX_VALUE) .addComponent(jCSerie, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(26, 26, 26))); getContentPane().add(jPanel3); javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); jPanel4.setLayout(jPanel4Layout); jPanel4Layout.setHorizontalGroup(jPanel4Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 133, Short.MAX_VALUE)); jPanel4Layout.setVerticalGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 75, Short.MAX_VALUE)); getContentPane().add(jPanel4); javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5); jPanel5.setLayout(jPanel5Layout); jPanel5Layout.setHorizontalGroup(jPanel5Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 133, Short.MAX_VALUE)); jPanel5Layout.setVerticalGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 75, Short.MAX_VALUE)); getContentPane().add(jPanel5); jBValider.setText("Valider"); jBValider.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jBValiderActionPerformed(evt); } }); javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7); jPanel7.setLayout(jPanel7Layout); jPanel7Layout .setHorizontalGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel7Layout.createSequentialGroup().addGap(33, 33, 33).addComponent(jBValider) .addContainerGap(35, Short.MAX_VALUE))); jPanel7Layout.setVerticalGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel7Layout.createSequentialGroup().addGap(23, 23, 23).addComponent(jBValider) .addContainerGap(29, Short.MAX_VALUE))); getContentPane().add(jPanel7); pack(); }// </editor-fold>//GEN-END:initComponents private void jBValiderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBValiderActionPerformed Serie s = new Serie(jTTitre.getText(), jTSynopsis.getText()); s.setPays(paysComboBoxModel.getPays(jCSerie.getSelectedIndex())); serieService.ajouter(s); jPListeSerie.rafraichirJTable(); this.setVisible(false); }//GEN-LAST:event_jBValiderActionPerformed private void jCSerieActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCSerieActionPerformed // TODO add your handling code here: }//GEN-LAST:event_jCSerieActionPerformed /** * @param args the command line arguments */ // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jBValider; private javax.swing.JComboBox<String> jCSerie; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private javax.swing.JPanel jPanel4; private javax.swing.JPanel jPanel5; private javax.swing.JPanel jPanel6; private javax.swing.JPanel jPanel7; private javax.swing.JTextField jTSynopsis; private javax.swing.JTextField jTTitre; // End of variables declaration//GEN-END:variables }