Package IHM

Source Code of IHM.Menu

package IHM;

import java.awt.Panel;

import javax.swing.JFrame;
import javax.swing.JPanel;

import metier.Question;

import com.services.JQuestions;

/**
*
* @author Alexandre
*/
public class Menu extends javax.swing.JPanel {
    private Frame frame;
    private Question[] questions1;
    private Question[] questions2;
    private Question q1;
    private int nbQuestions;

    public Menu(Frame f) {
        initComponents();
        frame = f;

        nbQuestions = 3 ;
        q1 =  frame.getQuestion1();
        questions1 = new Question[nbQuestions];
        /*questions1[0]=q1;
        questions1[1]=q1;
        questions1[2]=q1;*/
       
        JQuestions jQ2 = new JQuestions(nbQuestions);
        questions1 = jQ2.getQuestions();
       
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                         
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jButton3 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();

        setBackground(new java.awt.Color(222, 41, 16));

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ressources/Roue_elements.png"))); // NOI18N

        jButton3.setBackground(new java.awt.Color(222, 41, 16));
        jButton3.setForeground(new java.awt.Color(222, 41, 16));
        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ressources/Options.png"))); // NOI18N
        jButton3.setBorder(null);
        jButton3.setBorderPainted(false);
        jButton3.setContentAreaFilled(false);
        jButton3.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jButton2.setBackground(new java.awt.Color(222, 41, 16));
        jButton2.setForeground(new java.awt.Color(222, 41, 16));
        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ressources/Scores.png"))); // NOI18N
        jButton2.setBorder(null);
        jButton2.setBorderPainted(false);
        jButton2.setContentAreaFilled(false);
        jButton2.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton1.setBackground(new java.awt.Color(222, 41, 16));
        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ressources/NewGame.png"))); // NOI18N
        jButton1.setToolTipText("");
        jButton1.setBorder(null);
        jButton1.setBorderPainted(false);
        jButton1.setContentAreaFilled(false);
        jButton1.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ressources/Logo_Jeu.png"))); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(54, 54, 54)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel2)
                    .addComponent(jButton2)
                    .addComponent(jButton3)
                    .addComponent(jButton1))
                .addGap(23, 23, 23))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addGap(28, 28, 28)
                .addComponent(jButton1)
                .addGap(18, 18, 18)
                .addComponent(jButton2)
                .addGap(18, 18, 18)
                .addComponent(jButton3)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addContainerGap())
        );
    }// </editor-fold>                       

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
        JPanel p = new Jeu(frame, questions1, nbQuestions, 0, 0);
        frame.setPanel(p);
    }                                       

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                        
        JPanel p = new Scores(frame);
        frame.setPanel(p);
    }                                       

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {                                        
        JPanel p = new Options(frame);
        frame.setPanel(p);
    }                                       


    // Variables declaration - do not modify                    
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    // End of variables declaration                  
}
TOP

Related Classes of IHM.Menu

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.