elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Recuerda que debes registrarte en el foro para poder participar (preguntar y responder)


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  Java
| | | |-+  duda sobre un error
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: duda sobre un error  (Leído 1,308 veces)
elbrujo20

Desconectado Desconectado

Mensajes: 33


Ver Perfil
duda sobre un error
« en: 5 Mayo 2016, 09:01 am »

Buenas comunidad ando haciendo mi proyecto final sobre alquiler de peliculas pero tengo una duda sobre el error bueno ya tengo casi todo hecho codigo y grafico pero se tiene que enlazar a una base de datos para que salgan todas las  peliculas que quiero que muestre el error es la clase maindb linea 27 y 37 la del 27es del metodo obtener no entiendo por que da error y la 37 problemas con el cathc

Código
  1. import java.util.List;
  2. import java.util.logging.Level;
  3. import java.util.logging.Logger;
  4.  
  5. /**
  6.  *
  7.  * @author
  8.  */
  9. public class maindb {
  10.  
  11.  
  12.  
  13.    /**
  14.      * @param args the command line arguments
  15.      */
  16.    public static void main(String[] args) {
  17.        Pelicula item = new Pelicula(15,"Pantalon azul",700);
  18.        Peliculas bd = new Peliculas();
  19.  
  20.        try {
  21.            //bd.guardarProducto(BaseDatos.obtener(), item);
  22.            //item = bd.recuperarPorId(BaseDatos.obtener(), 100);
  23.            //System.out.println("Descripcion: " + item.getDescripcion());
  24.            //System.out.println("Precio: " + item.getPrecio());
  25.            //bd.eliminarPorId(BaseDatos.obtener(), 500);
  26.            List<Pelicula> lista = bd.recuperarTodas(Pelicula.obtener());
  27.  
  28.            for(int i=0; i<lista.size(); i++){
  29.                System.out.println("\nID: " + lista.get(i).getId());
  30.                System.out.println("Nombre: " + lista.get(i).getNombre());
  31.                System.out.println("Precio: " + lista.get(i).getPrecio());
  32.            }
  33.            Peliculas.cerrar();
  34.        } catch (ClassNotFoundException ex) {
  35.            Logger.getLogger(maindb.class.getName()).log(Level.SEVERE, null, ex);
  36.        }
  37.    }
  38.  
  39. }
  40.  
  41.  
Código
  1. java.sql.ResultSet;
  2. import java.sql.SQLException;
  3. import java.util.ArrayList;
  4. import java.util.List;
  5.  
  6. /**
  7.  *
  8.  * @author
  9.  */
  10. public class bd {
  11.  
  12. /*
  13.  * To change this license header, choose License Headers in Project Properties.
  14.  * To change this template file, choose Tools | Templates
  15.  * and open the template in the editor.
  16.  */
  17.  
  18. /**
  19.  *
  20.  * @author
  21.  */
  22.  
  23.    private static Connection cnx = null;
  24.    private String tabla = "pelicula";
  25.    private String bd = "videoclub";
  26.  
  27.    public static Connection obtener() throws SQLException, ClassNotFoundException {
  28.        if (cnx == null) {
  29.            try {
  30.                Class.forName("com.mysql.jdbc.Driver");
  31.                cnx = DriverManager.getConnection("jdbc:mysql://localhost/videoclub", "root", "");
  32.            } catch (SQLException ex) {
  33.                throw new SQLException(ex);
  34.            } catch (ClassNotFoundException ex) {
  35.                throw new ClassCastException(ex.getMessage());
  36.            }
  37.        }
  38.        return cnx;
  39.    }
  40.  
  41.    public static void cerrar() throws SQLException {
  42.        if (cnx != null) {
  43.            cnx.close();
  44.        }
  45.    }
  46.  
  47.    public void guardarProducto(Connection conexion, Pelicula item) throws SQLException{
  48.      try{
  49.         PreparedStatement consulta = null;
  50.         if(item.getId() > 0){
  51.            consulta = conexion.prepareStatement("INSERT INTO " + this.tabla + "(id, descripcion, precio) VALUES(?, ?, ?)");
  52.            consulta.setInt(1, item.getId());
  53.            consulta.setString(2, item.getnombre());
  54.            consulta.setFloat(3, item.getPrecio());
  55.         }
  56.         /*
  57.          else{
  58.             consulta = conexion.prepareStatement("UPDATE " + this.tabla + " SET titulo = ?, descripcion = ?, nivel_de_prioridad = ? WHERE id_tarea = ?");
  59.             consulta.setString(1, tarea.getTitulo());
  60.             consulta.setString(2, tarea.getDescripcion());
  61.             consulta.setInt(3, tarea.getNivel_de_prioridad());
  62.             consulta.setInt(4, tarea.getId_tarea());
  63.          } */
  64.         consulta.executeUpdate();
  65.      }catch(SQLException ex){
  66.         throw new SQLException(ex);
  67.      }
  68.   }
  69.  
  70.   public Pelicula recuperarPorId(Connection conexion, int id) throws SQLException {
  71.      Pelicula p = null;
  72.      try{
  73.         PreparedStatement consulta = conexion.prepareStatement("SELECT descripcion, precio FROM " + this.tabla + " WHERE id = ?" );
  74.         consulta.setInt(1, id);
  75.         ResultSet resultado = consulta.executeQuery();
  76.         while(resultado.next()){
  77.            p = new Pelicula(id, resultado.getString("nombre"), resultado.getFloat("precio"));
  78.         }
  79.      }catch(SQLException ex){
  80.         throw new SQLException(ex);
  81.      }
  82.      return p;
  83.   }
  84.  
  85.   public void eliminarPorId(Connection conexion,  int id) throws SQLException{
  86.      try{
  87.         PreparedStatement consulta = conexion.prepareStatement("DELETE FROM " + this.tabla + " WHERE id = ?");
  88.         consulta.setInt(1, id);
  89.         consulta.executeUpdate();
  90.      }catch(SQLException ex){
  91.         throw new SQLException(ex);
  92.      }
  93.   }
  94.  
  95.   public List<Pelicula> recuperarTodas(Connection conexion) throws SQLException{
  96.      List<Pelicula> lista = new ArrayList<>();
  97.      try{
  98.         PreparedStatement consulta = conexion.prepareStatement("SELECT id, descripcion, precio FROM " + this.tabla + " ORDER BY id");
  99.         ResultSet resultado = consulta.executeQuery();
  100.         while(resultado.next()){
  101.            lista.add(new Pelicula(resultado.getInt("id"), resultado.getString("nombre"), resultado.getFloat("precio")));
  102.         }
  103.      }catch(SQLException ex){
  104.         throw new SQLException(ex);
  105.      }
  106.      return lista;
  107.   }
  108.  
  109. }
  110.  
  111.  

Código
  1. import java.util.Calendar;
  2. import java.util.Scanner;
  3. import javax.swing.JOptionPane;
  4.  
  5. /**
  6.  *
  7.  * @author
  8.  */
  9. public class Peliculas extends javax.swing.JFrame {
  10.  
  11.    public String getObtener() {
  12.        return obtener;
  13.    }
  14.  
  15.    public void setObtener(String obtener) {
  16.        this.obtener = obtener;
  17.    }
  18.    String obtener;
  19.  
  20.    static void cerrar() {
  21.        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
  22.    }
  23.  
  24.    /**
  25.      * Creates new form Peliculas
  26.      */
  27.    public Peliculas() {
  28.        initComponents();
  29.    }
  30.  
  31.    /**
  32.      * This method is called from within the constructor to initialize the form.
  33.      * WARNING: Do NOT modify this code. The content of this method is always
  34.      * regenerated by the Form Editor.
  35.      */
  36.    @SuppressWarnings("unchecked")
  37.    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
  38.    private void initComponents() {
  39.  
  40.        Categorias = new javax.swing.JPanel();
  41.        jTextField1 = new javax.swing.JTextField();
  42.        jButton2 = new javax.swing.JButton();
  43.        jLabel1 = new javax.swing.JLabel();
  44.        jLabel2 = new javax.swing.JLabel();
  45.        jButton3 = new javax.swing.JButton();
  46.        jButton4 = new javax.swing.JButton();
  47.        jButton5 = new javax.swing.JButton();
  48.        jButton6 = new javax.swing.JButton();
  49.        jButton7 = new javax.swing.JButton();
  50.        jButton8 = new javax.swing.JButton();
  51.        jButton9 = new javax.swing.JButton();
  52.        jButton10 = new javax.swing.JButton();
  53.        Buscar = new javax.swing.JComboBox();
  54.        jTextField2 = new javax.swing.JTextField();
  55.        jTextField5 = new javax.swing.JTextField();
  56.        jTextField6 = new javax.swing.JTextField();
  57.        jButton1 = new javax.swing.JButton();
  58.        jButton11 = new javax.swing.JButton();
  59.        jButton12 = new javax.swing.JButton();
  60.        jToggleButton1 = new javax.swing.JToggleButton();
  61.  
  62.        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  63.        setBackground(new java.awt.Color(0, 0, 255));
  64.  
  65.        Categorias.setBackground(new java.awt.Color(0, 51, 204));
  66.        Categorias.setForeground(new java.awt.Color(0, 0, 204));
  67.        Categorias.setToolTipText("");
  68.        Categorias.setAutoscrolls(true);
  69.        Categorias.setName("Categorias"); // NOI18N
  70.  
  71.        jTextField1.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
  72.        jTextField1.setText("BUSCAR PELICULAS");
  73.        jTextField1.addActionListener(new java.awt.event.ActionListener() {
  74.            public void actionPerformed(java.awt.event.ActionEvent evt) {
  75.                jTextField1ActionPerformed(evt);
  76.            }
  77.        });
  78.  
  79.        jButton2.setFont(new java.awt.Font("Tahoma", 0, 10)); // NOI18N
  80.        jButton2.setText("SELECCIONAR");
  81.        jButton2.addActionListener(new java.awt.event.ActionListener() {
  82.            public void actionPerformed(java.awt.event.ActionEvent evt) {
  83.                jButton2ActionPerformed(evt);
  84.            }
  85.        });
  86.  
  87.        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
  88.        jLabel1.setText("GENEROS");
  89.  
  90.        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
  91.        jLabel2.setForeground(new java.awt.Color(0, 0, 51));
  92.        jLabel2.setText("PELICULA");
  93.  
  94.        jButton3.setText("ACCION");
  95.        jButton3.addActionListener(new java.awt.event.ActionListener() {
  96.            public void actionPerformed(java.awt.event.ActionEvent evt) {
  97.                jButton3ActionPerformed(evt);
  98.            }
  99.        });
  100.  
  101.        jButton4.setText("Ciencia Ficcion");
  102.        jButton4.addActionListener(new java.awt.event.ActionListener() {
  103.            public void actionPerformed(java.awt.event.ActionEvent evt) {
  104.                jButton4ActionPerformed(evt);
  105.            }
  106.        });
  107.  
  108.        jButton5.setText("Aventuras");
  109.        jButton5.addActionListener(new java.awt.event.ActionListener() {
  110.            public void actionPerformed(java.awt.event.ActionEvent evt) {
  111.                jButton5ActionPerformed(evt);
  112.            }
  113.        });
  114.  
  115.        jButton6.setText("Animacion");
  116.        jButton6.addActionListener(new java.awt.event.ActionListener() {
  117.            public void actionPerformed(java.awt.event.ActionEvent evt) {
  118.                jButton6ActionPerformed(evt);
  119.            }
  120.        });
  121.  
  122.        jButton7.setText("Comedias");
  123.        jButton7.addActionListener(new java.awt.event.ActionListener() {
  124.            public void actionPerformed(java.awt.event.ActionEvent evt) {
  125.                jButton7ActionPerformed(evt);
  126.            }
  127.        });
  128.  
  129.        jButton8.setText("Drama");
  130.        jButton8.addActionListener(new java.awt.event.ActionListener() {
  131.            public void actionPerformed(java.awt.event.ActionEvent evt) {
  132.                jButton8ActionPerformed(evt);
  133.            }
  134.        });
  135.  
  136.        jButton9.setText("Terror");
  137.        jButton9.addActionListener(new java.awt.event.ActionListener() {
  138.            public void actionPerformed(java.awt.event.ActionEvent evt) {
  139.                jButton9ActionPerformed(evt);
  140.            }
  141.        });
  142.  
  143.        jButton10.setText("Suspenso");
  144.        jButton10.addActionListener(new java.awt.event.ActionListener() {
  145.            public void actionPerformed(java.awt.event.ActionEvent evt) {
  146.                jButton10ActionPerformed(evt);
  147.            }
  148.        });
  149.  
  150.        Buscar.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
  151.        Buscar.setSelectedItem(Buscar);
  152.        Buscar.addActionListener(new java.awt.event.ActionListener() {
  153.            public void actionPerformed(java.awt.event.ActionEvent evt) {
  154.                BuscarActionPerformed(evt);
  155.            }
  156.        });
  157.  
  158.        javax.swing.GroupLayout CategoriasLayout = new javax.swing.GroupLayout(Categorias);
  159.        Categorias.setLayout(CategoriasLayout);
  160.        CategoriasLayout.setHorizontalGroup(
  161.            CategoriasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  162.            .addGroup(CategoriasLayout.createSequentialGroup()
  163.                .addContainerGap()
  164.                .addGroup(CategoriasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  165.                    .addGroup(CategoriasLayout.createSequentialGroup()
  166.                        .addGroup(CategoriasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  167.                            .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  168.                            .addComponent(Buscar, 0, 73, Short.MAX_VALUE))
  169.                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 330, Short.MAX_VALUE)
  170.                        .addGroup(CategoriasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  171.                            .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
  172.                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, CategoriasLayout.createSequentialGroup()
  173.                                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
  174.                                .addGap(24, 24, 24)))
  175.                        .addGap(41, 41, 41))
  176.                    .addGroup(CategoriasLayout.createSequentialGroup()
  177.                        .addGroup(CategoriasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  178.                            .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 231, javax.swing.GroupLayout.PREFERRED_SIZE)
  179.                            .addGroup(CategoriasLayout.createSequentialGroup()
  180.                                .addGroup(CategoriasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  181.                                    .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  182.                                    .addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE)
  183.                                    .addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  184.                                    .addComponent(jButton6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  185.                                .addGap(86, 86, 86)
  186.                                .addGroup(CategoriasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  187.                                    .addComponent(jButton9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  188.                                    .addComponent(jButton7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  189.                                    .addComponent(jButton8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  190.                                    .addComponent(jButton10, javax.swing.GroupLayout.DEFAULT_SIZE, 121, Short.MAX_VALUE))))
  191.                        .addGap(0, 236, Short.MAX_VALUE))))
  192.        );
  193.        CategoriasLayout.setVerticalGroup(
  194.            CategoriasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  195.            .addGroup(CategoriasLayout.createSequentialGroup()
  196.                .addGap(28, 28, 28)
  197.                .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  198.                .addGap(18, 18, 18)
  199.                .addGroup(CategoriasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  200.                    .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING)
  201.                    .addComponent(jLabel1))
  202.                .addGroup(CategoriasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  203.                    .addGroup(CategoriasLayout.createSequentialGroup()
  204.                        .addGap(18, 18, 18)
  205.                        .addComponent(jButton2))
  206.                    .addGroup(CategoriasLayout.createSequentialGroup()
  207.                        .addGap(10, 10, 10)
  208.                        .addComponent(Buscar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
  209.                .addGap(13, 13, 13)
  210.                .addGroup(CategoriasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  211.                    .addComponent(jButton3)
  212.                    .addGroup(CategoriasLayout.createSequentialGroup()
  213.                        .addGap(9, 9, 9)
  214.                        .addComponent(jButton7)))
  215.                .addGap(18, 18, 18)
  216.                .addGroup(CategoriasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  217.                    .addGroup(CategoriasLayout.createSequentialGroup()
  218.                        .addComponent(jButton8, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
  219.                        .addGap(32, 32, 32)
  220.                        .addComponent(jButton9))
  221.                    .addGroup(CategoriasLayout.createSequentialGroup()
  222.                        .addComponent(jButton4)
  223.                        .addGap(40, 40, 40)
  224.                        .addComponent(jButton5)))
  225.                .addGap(30, 30, 30)
  226.                .addGroup(CategoriasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  227.                    .addComponent(jButton10)
  228.                    .addComponent(jButton6))
  229.                .addGap(0, 51, Short.MAX_VALUE))
  230.        );
  231.  
  232.        jTextField2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
  233.        jTextField2.setForeground(new java.awt.Color(0, 0, 204));
  234.        jTextField2.setText("RENTAS");
  235.        jTextField2.addActionListener(new java.awt.event.ActionListener() {
  236.            public void actionPerformed(java.awt.event.ActionEvent evt) {
  237.                jTextField2ActionPerformed(evt);
  238.            }
  239.        });
  240.  
  241.        jTextField5.setText("Total a pagar");
  242.  
  243.        jTextField6.setText("15");
  244.  
  245.        jButton1.setText("VER FECHA DE RENTAS ABRIL");
  246.        jButton1.addActionListener(new java.awt.event.ActionListener() {
  247.            public void actionPerformed(java.awt.event.ActionEvent evt) {
  248.                jButton1ActionPerformed(evt);
  249.            }
  250.        });
  251.  
  252.        jButton11.setText("VER FECHA DE ENTREGAS ABRIL");
  253.        jButton11.addActionListener(new java.awt.event.ActionListener() {
  254.            public void actionPerformed(java.awt.event.ActionEvent evt) {
  255.                jButton11ActionPerformed(evt);
  256.            }
  257.        });
  258.  
  259.        jButton12.setText("VER FECHA DE RENTAS MAYO");
  260.        jButton12.addActionListener(new java.awt.event.ActionListener() {
  261.            public void actionPerformed(java.awt.event.ActionEvent evt) {
  262.                jButton12ActionPerformed(evt);
  263.            }
  264.        });
  265.  
  266.        jToggleButton1.setText("VER FECHAS DE ENTREGA MAYO");
  267.        jToggleButton1.addActionListener(new java.awt.event.ActionListener() {
  268.            public void actionPerformed(java.awt.event.ActionEvent evt) {
  269.                jToggleButton1ActionPerformed(evt);
  270.            }
  271.        });
  272.  
  273.        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  274.        getContentPane().setLayout(layout);
  275.        layout.setHorizontalGroup(
  276.            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  277.            .addGroup(layout.createSequentialGroup()
  278.                .addComponent(Categorias, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  279.                .addGap(0, 9, Short.MAX_VALUE))
  280.            .addGroup(layout.createSequentialGroup()
  281.                .addGap(22, 22, 22)
  282.                .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)
  283.                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  284.                .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
  285.                .addGap(85, 85, 85))
  286.            .addGroup(layout.createSequentialGroup()
  287.                .addContainerGap()
  288.                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
  289.                    .addComponent(jToggleButton1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 210, Short.MAX_VALUE)
  290.                    .addComponent(jButton1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  291.                    .addComponent(jButton11, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  292.                    .addComponent(jButton12, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
  293.                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  294.                .addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  295.                .addGap(97, 97, 97))
  296.        );
  297.        layout.setVerticalGroup(
  298.            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  299.            .addGroup(layout.createSequentialGroup()
  300.                .addComponent(Categorias, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  301.                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  302.                    .addGroup(layout.createSequentialGroup()
  303.                        .addGap(135, 135, 135)
  304.                        .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  305.                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  306.                        .addComponent(jButton1)
  307.                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  308.                        .addComponent(jButton11))
  309.                    .addGroup(layout.createSequentialGroup()
  310.                        .addGap(142, 142, 142)
  311.                        .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  312.                        .addGap(18, 18, 18)
  313.                        .addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
  314.                .addGap(18, 18, 18)
  315.                .addComponent(jButton12)
  316.                .addGap(18, 18, 18)
  317.                .addComponent(jToggleButton1)
  318.                .addGap(0, 122, Short.MAX_VALUE))
  319.        );
  320.  
  321.        pack();
  322.    }// </editor-fold>                        
  323.  
  324.    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {                                            
  325.        // TODO add your handling code here:
  326.  
  327.  
  328.  
  329.  
  330.  
  331.        String peliculas[]= new String[100];
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343.    }                                          
  344.  
  345.    private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {                                            
  346.        // TODO add your handling code here:
  347.  
  348.  
  349.    }                                          
  350.  
  351.    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {                                        
  352.        // TODO add your handling code here:
  353.        String peliculasdeaccion[]= {"Capitan America Civil War","Batman vs Superman",
  354.            "Rapido y Furioso 5","Terremoto en los angeles","Termintaor Genesis","Star wars 2015",
  355.               "Los vengadores la era de ultron","Mision Imposible 2015","Hombre Hormiga","Black hat"        
  356.        };
  357.        for(int x = 0;x<peliculasdeaccion.length; x++){
  358.            System.out.println(peliculasdeaccion[x]);
  359.  
  360.  
  361.    }                                        
  362.    }
  363.    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {                                        
  364.        // TODO add your handling code here:
  365.        String peliculascf[]={"Los juegos del hambre sinsajo","The Martian","Insurgente","Chapie","Mad Max", "\n"
  366.                +"El destino de Jupiter", "Area 51" ,"La rebeleion de Atlas" ,"Halo" ,"Turbo kid" ,"Los pro"};
  367.        for(int x = 0;x<peliculascf.length; x++){
  368.            System.out.println(peliculascf[x]);
  369.  
  370.        }
  371.    }                                        
  372.  
  373.    private void BuscarActionPerformed(java.awt.event.ActionEvent evt) {                                      
  374.        // TODO add your handling code here:
  375.    }                                      
  376.  
  377.    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {                                        
  378.        // TODO add your handling code here:
  379.        String peliculasaventuras[]={"Alien el octavo pasajero","Desterrado","Expediente warmen","\n"
  380.                + "Jurasic world", "\n"
  381.                +  "Vacaciones","Start trek","Xmen Apocalipsis","Dragon ball z resurrecion de frezer","\n"
  382.                +  "Warcraft el origen" ,"Un espia y medio"};
  383.        for(int x = 0; x<peliculasaventuras.length; x++){
  384.            System.out.println(peliculasaventuras[x]);
  385.  
  386.        }
  387.  
  388.    }                                        
  389.  
  390.    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {                                        
  391. // TODO add your handling code here:
  392.        String peliculasdeanimacion[]={"Minions","Home","Hotel transilvania","Carlitos y Snoopy","\n"
  393.                +  "La oveja shaun","Alvin y las ardillas","Pixeles","Strange Magic"};
  394.        for(int x =0; x<peliculasdeanimacion.length; x++){
  395.            System.out.println(peliculasdeanimacion[x]);
  396.  
  397.        }
  398.    }                                        
  399.  
  400.    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {                                        
  401.        // TODO add your handling code here:
  402.        String comedias[]={"Como acabar sin tu jefe2","Perdiendo el norte" ,"La fiesta de despedida","\n"
  403.               + "Superpoli en las Vegas","Hipocrates","Negocios con resaca","Los insolitos peces gato"
  404.                +  "Espias","Rey gitano","Ted 2"
  405.        };
  406.        for(int x =0; x<comedias.length; x++){
  407.            System.out.println(comedias[x]);
  408.        }  
  409.    }                                        
  410.  
  411.    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {                                        
  412.        // TODO add your handling code here:
  413.        String drama[]={"Frio en julio","Descifrando enigma","Whiplash","Desierto" ,"Demolicion","\n"
  414.        +  "Bosque de karadima","Enemigo invisible","Remeber","La ultima ola","Trumbo","La gran apuesta"};
  415.        for(int x =0; x<drama.length; x++){
  416.            System.out.println(drama[x]);
  417.        }
  418.  
  419.    }                                        
  420.  
  421.    private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {                                        
  422.        // TODO add your handling code here:
  423.        String terror[]={"La cumbre escarlata","Paranormal activyty 5","Sinister","Poltergeist","\n"
  424.            +  "La bruja","Los hijos del diablo","La visita","Demoniaco","Cuentos de halloween"};
  425.        for(int x =0; x<terror.length; x++){
  426.            System.out.println(terror[x]);
  427.        }
  428.    }                                        
  429.  
  430.    private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {                                          
  431.        // TODO add your handling code here:
  432.        String suspensos[]={"El regalo","Obsesion","El clan","El puente de los espias" ,"Mision imposible","\n"
  433.        +"La maldicion de charlie","Bus 657","Los jefes","Los intrusos","Caza el asesino"};
  434.        for(int x = 0; x<suspensos.length; x++){
  435.            System.out.println(suspensos[x]);
  436.  
  437.        }
  438.  
  439.    }                                        
  440.  
  441.    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                        
  442.        // TODO add your handling code here:
  443.        String s = JOptionPane.showInputDialog("Ingrese el nombre de la pelicula que desea rentar");
  444.        JOptionPane.showMessageDialog(null, "El precio de la renta es de 15pesos");
  445.  
  446.  
  447.  
  448.  
  449.    }                                        
  450.  
  451.    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
  452.        // TODO add your handling code here:
  453.        String rentasabril[]={"09 a las 22:30","10 a las 20:00" ,"11 a las 8:30","\n"
  454.        +"11 a las 5:30" ,"13 a las 20:00" ,"13 a las 21:45" ,"14 a las 20:00","\n"
  455.        +"14 a las 9:15","15 a las 20:20","20 a las 18:20" ,"25 a las 22:00" ,"30 a las 20:00"};
  456.        for(int x = 0; x<rentasabril.length; x++){
  457.            System.out.println(rentasabril[x]);
  458.  
  459.        }
  460.  
  461.    }                                        
  462.  
  463.    private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {                                          
  464.        // TODO add your handling code here:
  465.        String rentasmayo[]={"05 a las 22:30","08 a las 21:45","10 a las 20:25","\n"
  466.        +"12 a las 21:45" ,"13 a las 18:45" ,"14 a las 22:00", "14 a las 23:15", "\n"
  467.        +"15 a las 20:00" ,"18 a las 19:00" ,"18 a las 20:00" ,"21 a las 17:00" ,"24 alas 20:15","\n"
  468.        +"28 a las 22:08","30 a las 23:45"};
  469.        for(int x=0; x<rentasmayo.length; x++){
  470.            System.out.println(rentasmayo[x]);
  471.  
  472.        }
  473.    }                                        
  474.  
  475.    private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {                                          
  476.        // TODO add your handling code here:
  477.        String entregasabril[]={"10 a las 20:00" ,"11 a las  20:05" ,"13 a las 22:30 ","\n"
  478.        + "13 a las 5:45" ,"15 a las  20:08" ,"15 a las  23:05" ,"15 a las  23:45" , "\n"
  479.                + "15 a las 9:45" , "16 a las  22:05" ,"21 a las  18:45" , "26 a las 22:05","\n"
  480.                +"31 a las 23:50"
  481.        };
  482.        for(int x = 0; x<entregasabril.length; x++){
  483.            System.out.println(entregasabril[x]);
  484.        }
  485.  
  486.    }                                        
  487.  
  488.    private void jToggleButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                              
  489.        // TODO add your handling code here:
  490.        String entregasmayo[]={"06 a las 15:50" ,"10 a las  17:00" ,"11 a las  17:55","\n"
  491.        +"13 a las 20:00" ,"15 a las 21:15" ,"15 a las  22:00" ,"17 a las  18:25", "\n"
  492.        +"19 a las 22:20" ,"22 a las  18:05" ,"25 a  las  20:00" , "29 a las  20:05", "\n"
  493.         +"01 a las  17:15"};
  494.        for(int x=0; x<entregasmayo.length; x++){
  495.            System.out.print(entregasmayo[x]);
  496.        }
  497.  
  498.    }                                              
  499.  
  500.    /**
  501.      * @param args the command line arguments
  502.      */
  503.    public static void main(String args[]) {
  504.        /* Set the Nimbus look and feel */
  505.        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
  506.        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
  507.          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
  508.          */
  509.        try {
  510.            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  511.                if ("Nimbus".equals(info.getName())) {
  512.                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
  513.                    break;
  514.                }
  515.            }
  516.        } catch (ClassNotFoundException ex) {
  517.            java.util.logging.Logger.getLogger(Peliculas.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  518.        } catch (InstantiationException ex) {
  519.            java.util.logging.Logger.getLogger(Peliculas.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  520.        } catch (IllegalAccessException ex) {
  521.            java.util.logging.Logger.getLogger(Peliculas.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  522.        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  523.            java.util.logging.Logger.getLogger(Peliculas.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  524.        }
  525.        //</editor-fold>
  526.  
  527.        /* Create and display the form */
  528.        java.awt.EventQueue.invokeLater(new Runnable() {
  529.            public void run() {
  530.                new Peliculas().setVisible(true);
  531.            }
  532.        });
  533.    }
  534.    // Variables declaration - do not modify                    
  535.    private javax.swing.JComboBox Buscar;
  536.    private javax.swing.JPanel Categorias;
  537.    private javax.swing.JButton jButton1;
  538.    private javax.swing.JButton jButton10;
  539.    private javax.swing.JButton jButton11;
  540.    private javax.swing.JButton jButton12;
  541.    private javax.swing.JButton jButton2;
  542.    private javax.swing.JButton jButton3;
  543.    private javax.swing.JButton jButton4;
  544.    private javax.swing.JButton jButton5;
  545.    private javax.swing.JButton jButton6;
  546.    private javax.swing.JButton jButton7;
  547.    private javax.swing.JButton jButton8;
  548.    private javax.swing.JButton jButton9;
  549.    private javax.swing.JLabel jLabel1;
  550.    private javax.swing.JLabel jLabel2;
  551.    private javax.swing.JTextField jTextField1;
  552.    private javax.swing.JTextField jTextField2;
  553.    private javax.swing.JTextField jTextField5;
  554.    private javax.swing.JTextField jTextField6;
  555.    private javax.swing.JToggleButton jToggleButton1;
  556.    // End of variables declaration                  
  557.  
  558.    String getId() {
  559.        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
  560.    }
  561.  
  562.    String getPrecio() {
  563.        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
  564.    }
  565.  
  566.    String getNombre() {
  567.        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
  568.    }
  569. }
  570.  
  571.  
Saludos


« Última modificación: 6 Mayo 2016, 09:00 am por elbrujo20 » En línea

+ 1 Oculto(s)

Desconectado Desconectado

Mensajes: 298


un defecto se puede convertir en una virtud


Ver Perfil WWW
Re: duda sobre un error
« Respuesta #1 en: 6 Mayo 2016, 04:52 am »

Citar
Peliculas.cerrar();

creo que ese es el error!!!



 no uses el drag and drop de netbeans te genera codigo basura

bueno solo es un consejo ya que decis que es tu trabajo final




« Última modificación: 6 Mayo 2016, 05:03 am por simorg » En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
(duda sobre este foro) ¿Se puede poner links sobre programación?
Sugerencias y dudas sobre el Foro
Seyro97 5 4,007 Último mensaje 6 Febrero 2015, 17:55 pm
por el-brujo
Duda Urgente sobre error de definiciones de constantes en C++!!
Programación C/C++
flaurens 4 2,303 Último mensaje 24 Mayo 2015, 23:14 pm
por kub0x
Duda sobre un error en java
Java
elbrujo20 2 2,592 Último mensaje 26 Mayo 2015, 04:23 am
por 0xFer
Duda/Error sobre arrays (vectores)
Programación C/C++
Ikuza 1 1,699 Último mensaje 2 Diciembre 2015, 15:03 pm
por class_OpenGL
Duda sobre error
Programación C/C++
comemelguevo 1 1,360 Último mensaje 18 Enero 2016, 00:15 am
por class_OpenGL
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines