Vistas de página la semana pasada

martes, 14 de mayo de 2013

LA NUEVA CARA DE BROS PARADISE PROJECT

En estos días he venido realizando unas cuantas mejoras al proyecto, a continuación presento el nuevo menú principal de BROS PARADISE PROJECT:
Éste será el menú definitivo de mi proyecto, como el pasado cuenta con las opciones de historia e instrucciones pero la diferencia fundamental (aparte de la parte gráfica) es que no hay  opción para dos jugadores.
Con el menú anterior tenía los  inconvenientes  de no poder acomodar del todo bien la distribución de los botones en la pantalla (debido a los layouts) y también no poder insertar una imágen así que pasa éste nuevo menú decidí hacerlo por medio de formulario. De esta manera se solucionó el problema del layout y de la imágen.
Este es el código del menú con formulario JFrame y JPanel

//CLASE VENTANA1

package paradiseproject;

import javax.swing.JFrame;

/**
 *
 * @author ANDREA
 */
public class Ventana1 extends javax.swing.JFrame {
  

  
    public Ventana1() {
        initComponents();


    }

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

        fondoPrincipal1 = new paradiseproject.FondoPrincipal();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jButton1.setBackground(new java.awt.Color(255, 0, 51));
        jButton1.setForeground(new java.awt.Color(51, 51, 255));
        jButton1.setText("JUGAR!");
        jButton1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, null, new java.awt.Color(255, 51, 51), null, null));
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("HISTORIA");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton3.setText("INSTRUCCIONES");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout fondoPrincipal1Layout = new javax.swing.GroupLayout(fondoPrincipal1);
        fondoPrincipal1.setLayout(fondoPrincipal1Layout);
        fondoPrincipal1Layout.setHorizontalGroup(
            fondoPrincipal1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(fondoPrincipal1Layout.createSequentialGroup()
                .addGroup(fondoPrincipal1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(fondoPrincipal1Layout.createSequentialGroup()
                        .addGap(343, 343, 343)
                        .addComponent(jButton2))
                    .addGroup(fondoPrincipal1Layout.createSequentialGroup()
                        .addGap(320, 320, 320)
                        .addGroup(fondoPrincipal1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jButton3)
                            .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(330, Short.MAX_VALUE))
        );
        fondoPrincipal1Layout.setVerticalGroup(
            fondoPrincipal1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, fondoPrincipal1Layout.createSequentialGroup()
                .addContainerGap(296, Short.MAX_VALUE)
                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton3)
                .addGap(56, 56, 56))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(fondoPrincipal1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(fondoPrincipal1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>                       

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                        

        JFrame Ventana= new JFrame();
        Ventana.setVisible(true);
        Ventana.setSize(800,500);
        Ventana.setLocation(277,100);
        FondoHistoria miFondoHistoria= new FondoHistoria();
        Ventana.add(miFondoHistoria);
       

                // TODO add your handling code here:
    }                                       

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
        JFrame VentanaInstrucciones= new JFrame();
        VentanaInstrucciones.setVisible(true);
        VentanaInstrucciones.setSize(800,500);
        VentanaInstrucciones.setLocation(277,100);
        FondoInstrucciones miFondoInstrucciones= new FondoInstrucciones();
        VentanaInstrucciones.add(miFondoInstrucciones);
    }                                       

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
VentanaNivel1 miVentanaNivel1 = new VentanaNivel1();
miVentanaNivel1.setVisible(true);
miVentanaNivel1.setLocationRelativeTo(null);
    }                                       

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Ventana1().setVisible(true);

            }
        });
    }

    // Variables declaration - do not modify                    
    private paradiseproject.FondoPrincipal fondoPrincipal1;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    // End of variables declaration                  

}

Y por medio del siguiente código en el formulario JPanel introduje las imagenes:
//CLASE FONDO PRINCIPAL
package paradiseproject;
import java.awt.Dimension;
import java.awt.Graphics;
import javax.swing.ImageIcon;

/**
 *
 * @author ANDREA
 */
public class FondoPrincipal extends javax.swing.JPanel {

    /** Creates new form FondoPrincipal */
    public FondoPrincipal() {
        initComponents();
    }
  @Override
public void paintComponent(Graphics g) {
Dimension tam = getSize();
ImageIcon imagen = new ImageIcon(getClass().getResource("/imagen/BROS.png"));
g.drawImage(imagen.getImage(), 0, 0, tam.width, tam.height, null);
setOpaque(false);
super.paintComponent(g);

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

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );
    }// </editor-fold>                       


    // Variables declaration - do not modify                    
    // End of variables declaration                  

}

No hay comentarios:

Publicar un comentario