Beispiel #1
0
 /** El metodo actualizar se encarga del manejo del teclado y de movimiento de las imagenes */
 public void actualizar() {
   if (fondo1 != null) {
     fondo1.mover(10);
     fondo2.mover(10);
     fondo3.mover(10);
     fondo4.mover(10);
     puntajes.mover(1);
     ayuda.mover(1);
     creditos.mover(1);
     salir.mover(1);
     titulo.mover(1);
     menuPuntajes = null;
     menuAyuda = null;
     menuCreditos = null;
     menuSalir = null;
     menuInicio = null;
   }
   if (menuPuntajes != null) {
     try {
       menuPuntajes.actualizar();
     } catch (Exception ex) {
       ex.printStackTrace();
     }
   }
   if (menuAyuda != null) {
     try {
       menuAyuda.actualizar();
     } catch (Exception ex) {
       ex.printStackTrace();
     }
   }
   if (menuCreditos != null) {
     try {
       menuCreditos.actualizar();
     } catch (Exception ex) {
       ex.printStackTrace();
     }
   }
   if (menuSalir != null) {
     try {
       menuSalir.actualizar();
     } catch (Exception ex) {
       ex.printStackTrace();
     }
     if (menuSalir.getSalir()) {
       midlet.terminar();
       animador.terminar();
       midlet.detenerMusica();
       terminar = true;
     }
   }
   if (menuInicio != null) {
     try {
       menuInicio.actualizar();
     } catch (Exception ex) {
       ex.printStackTrace();
     }
   }
   if (highLight != null) {
     int estado = getKeyStates();
     if (estado == 0) {
       bandera = false;
     }
     if (highLight.getPrioridad() == juego.getPrioridad()) {
       if ((estado & UP_PRESSED) != 0 && !bandera) {
         highLight.setPosicion(puntajes.getX() - 1, puntajes.getY() - 1);
         highLight.setPrioridad(puntajes.getPrioridad());
         bandera = true;
       }
       if ((estado & DOWN_PRESSED) != 0 && !bandera) {
         highLight.setPosicion(salir.getX(), salir.getY());
         highLight.setPrioridad(salir.getPrioridad());
         bandera = true;
       }
       if ((estado & FIRE_PRESSED) != 0 && !bandera) {
         menuInicio = new Inicio(this);
         borrarTodo();
         bandera = true;
       }
     } else if (highLight.getPrioridad() == creditos.getPrioridad()) {
       if ((estado & UP_PRESSED) != 0 && !bandera) {
         highLight.setPosicion(juego.getX(), juego.getY());
         highLight.setPrioridad(juego.getPrioridad());
         bandera = true;
       }
       if ((estado & LEFT_PRESSED) != 0 && !bandera) {
         highLight.setPosicion(salir.getX(), salir.getY());
         highLight.setPrioridad(salir.getPrioridad());
         bandera = true;
       }
       if ((estado & FIRE_PRESSED) != 0) {
         menuCreditos = new Creditos(this);
         borrarTodo();
         bandera = true;
       }
     } else if (highLight.getPrioridad() == puntajes.getPrioridad()) {
       if ((estado & RIGHT_PRESSED) != 0 && !bandera) {
         highLight.setPosicion(ayuda.getX(), ayuda.getY());
         highLight.setPrioridad(ayuda.getPrioridad());
         bandera = true;
       }
       if ((estado & DOWN_PRESSED) != 0 && !bandera) {
         highLight.setPosicion(juego.getX(), juego.getY());
         highLight.setPrioridad(juego.getPrioridad());
         bandera = true;
       }
       if ((estado & FIRE_PRESSED) != 0) {
         try {
           menuPuntajes = new Puntajes(this, lecturaScores());
         } catch (IOException ex) {
           menuPuntajes = new Puntajes(this, "0");
         }
         borrarTodo();
         bandera = true;
       }
     } else if (highLight.getPrioridad() == salir.getPrioridad()) {
       if ((estado & RIGHT_PRESSED) != 0 && !bandera) {
         highLight.setPosicion(creditos.getX(), creditos.getY());
         highLight.setPrioridad(creditos.getPrioridad());
         bandera = true;
       }
       if ((estado & UP_PRESSED) != 0 && !bandera) {
         highLight.setPosicion(juego.getX(), juego.getY());
         highLight.setPrioridad(juego.getPrioridad());
         bandera = true;
       }
       if ((estado & FIRE_PRESSED) != 0) {
         menuSalir = new Salir(this);
         borrarTodo();
         bandera = true;
       }
     } else if (highLight.getPrioridad() == ayuda.getPrioridad()) {
       if ((estado & LEFT_PRESSED) != 0 && !bandera) {
         highLight.setPosicion(puntajes.getX(), puntajes.getY());
         highLight.setPrioridad(puntajes.getPrioridad());
         bandera = true;
       }
       if ((estado & DOWN_PRESSED) != 0 && !bandera) {
         highLight.setPosicion(juego.getX(), juego.getY());
         highLight.setPrioridad(juego.getPrioridad());
         bandera = true;
       }
       if ((estado & FIRE_PRESSED) != 0) {
         menuAyuda = new Ayuda(this);
         borrarTodo();
         bandera = true;
       }
     }
   }
 }
  @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    jDesktopPane = new javax.swing.JDesktopPane();
    BotonNuevoRegistro = new javax.swing.JButton();
    BotonEdicionRegistro = new javax.swing.JButton();
    BarraMenu = new javax.swing.JMenuBar();
    archivo = new javax.swing.JMenu();
    MenuNuevoregistro = new javax.swing.JMenuItem();
    MenuEdicionRegistro = new javax.swing.JMenuItem();
    MenuLogeo = new javax.swing.JMenuItem();
    MenuSalir = new javax.swing.JMenuItem();
    Ayuda = new javax.swing.JMenu();

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

    jDesktopPane.setBackground(new java.awt.Color(204, 204, 255));

    BotonNuevoRegistro.setText("Ingreso Nuevo Registro");
    BotonNuevoRegistro.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            BotonNuevoRegistroActionPerformed(evt);
          }
        });
    BotonNuevoRegistro.setBounds(90, 210, 170, 23);
    jDesktopPane.add(BotonNuevoRegistro, javax.swing.JLayeredPane.DEFAULT_LAYER);

    BotonEdicionRegistro.setText("Edición Registro");
    BotonEdicionRegistro.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            BotonEdicionRegistroActionPerformed(evt);
          }
        });
    BotonEdicionRegistro.setBounds(430, 210, 130, 23);
    jDesktopPane.add(BotonEdicionRegistro, javax.swing.JLayeredPane.DEFAULT_LAYER);

    archivo.setText("Archivo");

    MenuNuevoregistro.setText("Nuevo registro");
    MenuNuevoregistro.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            MenuNuevoregistroActionPerformed(evt);
          }
        });
    archivo.add(MenuNuevoregistro);

    MenuEdicionRegistro.setText("Edición registro");
    MenuEdicionRegistro.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            MenuEdicionRegistroActionPerformed(evt);
          }
        });
    archivo.add(MenuEdicionRegistro);

    MenuLogeo.setText("Logeo");
    MenuLogeo.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            MenuLogeoActionPerformed(evt);
          }
        });
    archivo.add(MenuLogeo);

    MenuSalir.setAccelerator(
        javax.swing.KeyStroke.getKeyStroke(
            java.awt.event.KeyEvent.VK_Q, java.awt.event.InputEvent.CTRL_MASK));
    MenuSalir.setText("Salir");
    MenuSalir.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            MenuSalirActionPerformed(evt);
          }
        });
    archivo.add(MenuSalir);

    BarraMenu.add(archivo);

    Ayuda.setText("Ayuda");
    BarraMenu.add(Ayuda);

    setJMenuBar(BarraMenu);

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

    pack();
    setLocationRelativeTo(null);
  } // </editor-fold>//GEN-END:initComponents
Beispiel #3
0
  /** Este metodo te permite dibujar todas las opciones del menu asi como los respectivos fondos. */
  public void dibujar() {
    if (logoTec != null) {
      dibujarLogoTec();
    }
    logoTec = null;
    if (fondo4 != null) {
      fondo1.dibujar(g);
      fondo2.dibujar(g);
      fondo3.dibujar(g);
      fondo4.dibujar(g);
      if (fondo4.getY() >= 108) {
        puntajes.dibujar(g);
        if (highLight.getPrioridad() == puntajes.getPrioridad()) {
          tituloPuntajes.dibujar(g);
        }

        ayuda.dibujar(g);
        if (highLight.getPrioridad() == ayuda.getPrioridad()) {
          tituloAyuda.dibujar(g);
        }

        creditos.dibujar(g);
        if (highLight.getPrioridad() == creditos.getPrioridad()) {
          tituloCreditos.dibujar(g);
        }

        salir.dibujar(g);
        if (highLight.getPrioridad() == salir.getPrioridad()) {
          tituloSalir.dibujar(g);
        }

        juego.dibujar(g);
        if (puntajes.getX() <= 20) {
          if (highLight.getPrioridad() == juego.getPrioridad()) {
            tituloJuego1.dibujar(g);
            tituloJuego2.dibujar(g);
            tituloJuego3.dibujar(g);
            tituloJuego4.dibujar(g);
          }
        }

        highLight.dibujar(g);
        titulo.dibujar(g);
      }
    }

    if (menuPuntajes != null) {
      menuPuntajes.g = this.getGraphics();
      menuPuntajes.dibujar();
    }

    if (menuAyuda != null) {
      menuAyuda.g = this.getGraphics();
      menuAyuda.dibujar();
    }

    if (menuCreditos != null) {
      menuCreditos.g = this.getGraphics();
      menuCreditos.dibujar();
    }

    if (menuSalir != null) {
      menuSalir.g = this.getGraphics();
      menuSalir.dibujar();
    }

    if (menuInicio != null) {
      menuInicio.g = this.getGraphics();
      menuInicio.dibujar();
    }

    flushGraphics();
  }