streaming.gui.JFramePrincipale.java Source code

Java tutorial

Introduction

Here is the source code for streaming.gui.JFramePrincipale.java

Source

/*
 * 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 java.awt.BorderLayout;
import javax.swing.JPanel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import org.springframework.stereotype.Component;

/**
 *
 * @author admin
 */
@Component
public class JFramePrincipale extends javax.swing.JFrame {

    @Autowired
    private JPanelListeSerie jpListeFilm;

    @Autowired
    private JPanelListeRealisateur jPanelListeRealisateur;

    @Autowired
    private JPanelListeFilm jPanelListeFilm;

    @Autowired
    private JPanelListeGenre jPanelListeGenre;

    /**
     * Creates new form JFramePrincipale
     */
    private JPanel jpCentral = null;

    public JFramePrincipale() {
        initComponents();
    }

    private void supprimerPanneaux() {
        if (jpCentral == null) {
            return;
        }
        //supprime le panneau central
        this.remove(this.jpCentral);
        jpCentral = null;
    }

    /**
     * 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() {

        jToolBar1 = new javax.swing.JToolBar();
        jbFilm = new javax.swing.JButton();
        jbSerie = new javax.swing.JButton();
        jbPays = new javax.swing.JButton();
        jbReal = new javax.swing.JButton();
        jbGenre = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Streaming");

        jToolBar1.setRollover(true);

        jbFilm.setText("Film");
        jbFilm.setFocusable(false);
        jbFilm.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jbFilm.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jbFilm.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbFilmActionPerformed(evt);
            }
        });
        jToolBar1.add(jbFilm);

        jbSerie.setText("Srie");
        jbSerie.setFocusable(false);
        jbSerie.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jbSerie.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jbSerie.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbSerieActionPerformed(evt);
            }
        });
        jToolBar1.add(jbSerie);

        jbPays.setText("Pays");
        jbPays.setFocusable(false);
        jbPays.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jbPays.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jbPays.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbPaysActionPerformed(evt);
            }
        });
        jToolBar1.add(jbPays);

        jbReal.setText("Ralisateur");
        jbReal.setFocusable(false);
        jbReal.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jbReal.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jbReal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbRealActionPerformed(evt);
            }
        });
        jToolBar1.add(jbReal);

        jbGenre.setText("Genre");
        jbGenre.setFocusable(false);
        jbGenre.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jbGenre.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jbGenre.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbGenreActionPerformed(evt);
            }
        });
        jToolBar1.add(jbGenre);

        getContentPane().add(jToolBar1, java.awt.BorderLayout.NORTH);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jbFilmActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbFilmActionPerformed
        // Accs  la catgorie film
        supprimerPanneaux();

        jpCentral = jPanelListeFilm;
        add(jpCentral, BorderLayout.CENTER);

        jPanelListeFilm.setjFrameP(this);
        jPanelListeFilm.rafraichir();

    }//GEN-LAST:event_jbFilmActionPerformed

    private void jbSerieActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbSerieActionPerformed
        // Accs  la catgorie srie
        supprimerPanneaux();

        jpListeFilm.rafraichirJTable();
        jpCentral = jpListeFilm;
        add(jpCentral, BorderLayout.CENTER);
        this.pack();

    }//GEN-LAST:event_jbSerieActionPerformed

    private void jbGenreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbGenreActionPerformed
        // Accs  la catgorie genre
        supprimerPanneaux();

        jpCentral = jPanelListeGenre;
        add(jpCentral, BorderLayout.CENTER);

        jPanelListeGenre.rafraichir();

        this.pack();
    }//GEN-LAST:event_jbGenreActionPerformed

    private void jbPaysActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbPaysActionPerformed
        // Accs  la catgorie pays
        supprimerPanneaux();

        jpCentral = new JPanelListePays();
        add(jpCentral, BorderLayout.CENTER);

        jPanelListeGenre.rafraichir();

        this.pack();
    }//GEN-LAST:event_jbPaysActionPerformed

    private void jbRealActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbRealActionPerformed
        // Accs  la catgorie ralisateur
        supprimerPanneaux();

        jPanelListeRealisateur.rafraichirJTable();
        jpCentral = jPanelListeRealisateur;
        add(jpCentral, BorderLayout.CENTER);
        this.pack();
    }//GEN-LAST:event_jbRealActionPerformed

    /**
     * @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;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(JFramePrincipale.class.getName()).log(java.util.logging.Level.SEVERE,
                    null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(JFramePrincipale.class.getName()).log(java.util.logging.Level.SEVERE,
                    null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(JFramePrincipale.class.getName()).log(java.util.logging.Level.SEVERE,
                    null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(JFramePrincipale.class.getName()).log(java.util.logging.Level.SEVERE,
                    null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {

                ApplicationContext context = new FileSystemXmlApplicationContext(
                        "file:/C:\\Users\\admin\\Documents\\NetBeansProjects\\Streaming\\application-context.xml");
                JFramePrincipale jfp = context.getBean(JFramePrincipale.class);
                jfp.setSize(800, 600);
                jfp.setVisible(true);

            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JButton jbFilm;
    private javax.swing.JButton jbGenre;
    private javax.swing.JButton jbPays;
    private javax.swing.JButton jbReal;
    private javax.swing.JButton jbSerie;
    // End of variables declaration//GEN-END:variables
}