Buscar este blog

jueves, 4 de abril de 2013

Clase menú principal de dominz

A continuación comparto el código de la clase del menú principal de dominz, el cual se encarga de enlazar los resultados obtenidos en la elección del color de la ficha y el correspondiente juego.


package dominz;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class Mennu implements MouseListener {
     Font mi = new java.awt.Font("Tahoma", 1, 12);
      JFrame miventana=new JFrame();
       JLabel milabel =new JLabel();
        JButton miboton1=new JButton();
         JButton miboton2=new JButton();
          JButton miboton3=new JButton();
      juego mijuego=new juego();
      Options miopcion=new Options();
      Controls  micontrol =new Controls();
      instrucciones1 miinstruccion=new instrucciones1();
       Mico mico=new Mico();
    
      public void menu(){
       
         
          milabel.setSize(600, 450);
          
          miventana.setResizable(false);
        miventana.setSize(600, 450);
        miventana.setLayout(null);
        miventana.setLocationRelativeTo(null);
        miventana.add(miboton1);
        miventana.add(miboton2);
        miventana.add(miboton3);
        miventana.add(milabel);
        miboton1.setBounds(200, 100, 200, 40);
        miboton1.setText("JUEGO NUEVO");
        miboton1.setForeground(Color.red);
        miboton1.setFont(mi);
         miboton2.setBounds(200, 150, 200, 40);
         miboton2.setText("OPCIONES");
        miboton2.setFont(mi);
        miboton2.setForeground(Color.red);
          miboton3.setBounds(200,200, 200, 40);
          miboton3.setText("INSTRUCCIONES DE JUEGO");
        miboton3.setFont(mi);
        miboton3.setForeground(Color.red);
        milabel.setIcon(new ImageIcon("domino.png"));
        
        miboton1.addMouseListener(this);
        miboton2.addMouseListener(this);
        miboton3.addMouseListener(this);
        miventana.setVisible(true);
         
    }

   

    @Override
    public void mouseClicked(MouseEvent e) {
       if(e.getSource()==miboton1){
           mico.ven();
             int a;
         
                a=mico.color();
           if(a==1){
              
               mijuego.ventana1(a);
              
           }
          if(a==2){
               System.out.print("1");
               mijuego.ventana1(a);
           }
          if(a==3){
              
               mijuego.ventana1(a);
           }
          if(a==4){
              
               mijuego.ventana1(a);
           }
      
       }
        if(e.getSource()==miboton2){
        miopcion.menu();
      
     
       }
        if(e.getSource()==miboton3){
        miinstruccion.menu();
    
     
       }
    }

    @Override
    public void mousePressed(MouseEvent e) {
       
    }

    @Override
    public void mouseReleased(MouseEvent e) {
       
    }

    @Override
    public void mouseEntered(MouseEvent e) {
        
    }

    @Override
    public void mouseExited(MouseEvent e) {
      
    }
    
}

No hay comentarios:

Publicar un comentario