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 java.awt.BorderLayout; import javax.swing.JFrame; 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 PrincipaleJFrame extends javax.swing.JFrame { private JPanel jPCentrale = null; @Autowired private FilmJPanelList filmJPanelList; @Autowired private SerieJPanelList serieJPanelList; @Autowired private GenreJPanelList genreJPanelList; public PrincipaleJFrame() { 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() { jToolBar1 = new javax.swing.JToolBar(); jBFilm = new javax.swing.JButton(); jBSerie = new javax.swing.JButton(); jBGenre = new javax.swing.JButton(); jBPays = new javax.swing.JButton(); jBReal = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Streaming"); jToolBar1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true)); jToolBar1.setFloatable(false); jToolBar1.setRollover(true); jToolBar1.setAlignmentY(0.5F); jToolBar1.setMaximumSize(new java.awt.Dimension(500, 30)); jToolBar1.setMinimumSize(new java.awt.Dimension(500, 30)); jToolBar1.setPreferredSize(new java.awt.Dimension(500, 30)); jBFilm.setText("Film"); jBFilm.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jBFilm.setFocusable(false); jBFilm.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jBFilm.setMaximumSize(new java.awt.Dimension(600, 30)); jBFilm.setMinimumSize(new java.awt.Dimension(100, 30)); jBFilm.setName(""); // NOI18N jBFilm.setPreferredSize(new java.awt.Dimension(100, 30)); 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.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jBSerie.setFocusable(false); jBSerie.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jBSerie.setMaximumSize(new java.awt.Dimension(600, 30)); jBSerie.setMinimumSize(new java.awt.Dimension(100, 30)); jBSerie.setName(""); // NOI18N jBSerie.setPreferredSize(new java.awt.Dimension(100, 30)); 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); jBGenre.setText("Genre"); jBGenre.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jBGenre.setFocusable(false); jBGenre.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jBGenre.setMaximumSize(new java.awt.Dimension(600, 30)); jBGenre.setMinimumSize(new java.awt.Dimension(100, 30)); jBGenre.setName(""); // NOI18N jBGenre.setPreferredSize(new java.awt.Dimension(100, 30)); 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); jBPays.setText("Pays"); jBPays.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jBPays.setFocusable(false); jBPays.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jBPays.setMaximumSize(new java.awt.Dimension(600, 30)); jBPays.setMinimumSize(new java.awt.Dimension(100, 30)); jBPays.setName(""); // NOI18N jBPays.setPreferredSize(new java.awt.Dimension(100, 30)); 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.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jBReal.setFocusable(false); jBReal.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jBReal.setMaximumSize(new java.awt.Dimension(600, 30)); jBReal.setMinimumSize(new java.awt.Dimension(100, 30)); jBReal.setName(""); // NOI18N jBReal.setPreferredSize(new java.awt.Dimension(100, 30)); 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); 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 supprimer(); filmJPanelList.rafraichirJTable(); jPCentrale = filmJPanelList; add(jPCentrale, BorderLayout.CENTER); pack(); }//GEN-LAST:event_jBFilmActionPerformed private void jBSerieActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBSerieActionPerformed supprimer(); serieJPanelList.rafraichirJTable(); jPCentrale = serieJPanelList; add(jPCentrale, BorderLayout.CENTER); pack(); }//GEN-LAST:event_jBSerieActionPerformed private void jBGenreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBGenreActionPerformed supprimer(); jPCentrale = genreJPanelList; this.add(jPCentrale, BorderLayout.CENTER); }//GEN-LAST:event_jBGenreActionPerformed private void jBPaysActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBPaysActionPerformed supprimer(); // jPCentrale = new PaysJPanelList(); this.add(jPCentrale, BorderLayout.CENTER); }//GEN-LAST:event_jBPaysActionPerformed private void jBRealActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBRealActionPerformed supprimer(); // jPCentrale = new RealJPanelList(); this.add(jPCentrale, BorderLayout.CENTER); }//GEN-LAST:event_jBRealActionPerformed /** * @param args the command line arguments */ public void supprimer() { if (jPCentrale == null) { return; } this.remove(this.jPCentrale); jPCentrale = null; } public static void main(String args[]) { /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { String file1 = "file:/C:\\Users\\ajc\\Documents\\NetBeansProjects\\Streaming\\application-context.xml"; String file2 = "file:/C:\\Users\\admin\\Desktop\\Projets\\Streaming\\application-context.xml"; ApplicationContext context = new FileSystemXmlApplicationContext(file2); JFrame jf = context.getBean(PrincipaleJFrame.class); jf.setSize(800, 600); jf.setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables 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; private javax.swing.JToolBar jToolBar1; // End of variables declaration//GEN-END:variables }