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

 

 


Tema destacado: Como proteger una cartera - billetera de Bitcoin


  Mostrar Mensajes
Páginas: [1]
1  Programación / Java / Re: Ayuda, obtener datos de Objetos en ArrayList en: 28 Febrero 2015, 23:50 pm
Ya lo pude solucionar, faltaba pasar los datos por parámetro en la función. Los datos pasaban y cuando llegaban a la función "se borraban". Muchísimas gracias Gus y disculpa por no hacer las cosas debidamente, la  verdad estaba un tanto desesperado por que se me viene encima el examen y no podía ni hacer funcionar la aplicación de practica. Mil gracias por ayudar a los que comentaron!!!


Código
  1. public String getProductoMasCaro(ArrayList<Articulo> listaArticulos) { //esto soluciono el problema
  2.  
  3.  
  4.         masCaro =  listaArticulos.get(0);
  5.  
  6.  
  7.        for(Articulo articulo : listaArticulos) {
  8.            if(articulo.getPrecio()> masCaro.getPrecio())
  9.                masCaro = articulo;
  10.        }
  11.  
  12.             return masCaro.getNombre();
  13.  
  14.  
  15.  
  16.         }
2  Programación / Java / Re: Ayuda, obtener datos de Objetos en ArrayList en: 28 Febrero 2015, 23:12 pm
Debuggeando el programa nos da el error que esta detallado abajo, pero checkeando el tamaño de  "listaArticulos" (usando size(); en el arrayList) y efectivamente devuelve datos. 


Código
  1. public String getProductoMasCaro() {
  2.  
  3.            masCaro =  listaArticulos.get(0); // esta linea tira un error de Method "get" is called on null object.
  4.  
  5.            for(Articulo articulo : listaArticulos) {
  6.            if(articulo.getPrecio()> masCaro.getPrecio())
  7.            masCaro = articulo;
  8.        }
  9.  
  10.  
  11.             return masCaro.getNombre();
  12. }
3  Programación / Java / Re: Ayuda, obtener datos de Objetos en ArrayList en: 28 Febrero 2015, 08:46 am
Vuelvo aquí con mas dudas, el código de la parte Reportes es algo así, gracias a Gus me ilumino. Lo que tengo en duda es.... en el código

Código
  1. public ReporteArticulo(ArrayList<Articulo> listaArticulos) {
  2.  
  3.    }
  4.  
  5.    public int[] getExistenciaTiposProductos(int tipo) {
  6.        final int TODOS = -1;
  7.        final int TIPO_1 = 0;
  8.        final int TIPO_2 = 0;
  9.        int tipo1cantidad = 0;
  10.        int tipo2cantidad = 0;
  11.        int requestCategoryExistences = 0;
  12.  
  13.        for(Articulo articulo : listaArticulos) {
  14.            if(tipo != TODOS) {
  15.                if(articulo.getTipo() == tipo) {
  16.                    requestCategoryExistences++;
  17.                }
  18.            } else {
  19.                if(articulo.getTipo() == TIPO_1)
  20.                  tipo1cantidad++;
  21.                if(articulo.getTipo() == TIPO_2)
  22.                  tipo2cantidad++;
  23.            }
  24.        }
  25.        if(tipo != TODOS)
  26.            return new int[] { requestCategoryExistences };
  27.        else
  28.            return new int[] {tipo1cantidad, tipo2cantidad};  
  29.  
  30.  
  31.    }
  32.  
  33.  
  34.  
  35.     public Double getTotalDineroProductos() {
  36.        Double montoTotal = 0d;
  37.      for(Articulo articulo : listaArticulos) {
  38.            montoTotal += articulo.getPrecio();
  39.        }
  40.        return montoTotal;
  41.  
  42.  
  43.    }
  44.  
  45.     public Articulo getProductoMasCaro() {
  46.        Articulo masCaro = listaArticulos.get(0);
  47.  
  48.        for(Articulo articulo : listaArticulos) {
  49.            if(articulo.getPrecio()> masCaro.getPrecio())
  50.                masCaro = articulo;
  51.        }
  52.  
  53.        return masCaro;
  54.  
  55.    }
  56.  

Como lo hizo Gus comparaba los tipos según los datos ingresados un poco mas arriba, ahora.... yo a los datos los tengo en un ArrayList en donde estan TODOS los datos "codigo, tipo, precio,etc" si uso el codigo tal cual pero llamando a los datos del Array estaría recorriendo siempre el mismo Articulo? debería usar un interator?

4  Programación / Java / Re: Ayuda, obtener datos de Objetos en ArrayList en: 28 Febrero 2015, 01:31 am
Ahí organice un poco el despelote, gracias por sus respuestas voy a ponerme a terminar el ejercicio en base a tu ejemplo. Espero salga todo bien, gracias por tomarse el tiempo de darme una mano.
5  Programación / Java / Re: Ayuda, obtener datos de Objetos en ArrayList en: 27 Febrero 2015, 22:45 pm
Algunas cosas son auto generadas, digamos los JFrame si son auto generados y lo visual esta echo con el diseñador proporcionado por NetBeans.
6  Programación / Java / Re: Ayuda, obtener datos de Objetos en ArrayList en: 27 Febrero 2015, 22:43 pm
Perdon otra vez por el desorden.

Mi problema es lo que no esta, en realidad lo que necesito saber es como conseguir los valores de los atributos en especifico para responder a lo siguiente.

cantidad de productos de cada tipo.
total de dinero en artículos.
porcentaje de artículos de tipo 2.
Y articulo con el precio mas elevado.

Esta claro que es necesario utilizar un bucle for/ for each, pero no se como obtener esos datos. Si me podes tirar un ejemplo de una nomas de las consignas que puse arriba ya voy a saber por donde agarrar.

sobre lo de los 3 JFrame la verdad es que asi me enseñaron o me están enseñando mejor dicho. Estoy aprendiendo java. Pero la verdad es que no se me da bien programar.
7  Programación / Java / Re: Ayuda, obtener datos de Objetos en ArrayList en: 27 Febrero 2015, 22:19 pm
Ahí puse el código, supuse que iba a ser mas organizado ver cada clase separada. Disculpas~
8  Programación / Java / Ayuda, obtener datos de Objetos en ArrayList en: 27 Febrero 2015, 21:25 pm
Tengo que realizar un programa el cual Cargue artículos, muestre todos los artículos cargado y luego en otra ventana de consulta muestre:

cantidad de productos de cada tipo.
total de dinero en artículos.
porcentaje de artículos de tipo 2.
Y articulo con el precio mas elevado.

Ya realice la carga de artículos y la otra pantalla que muestra todos los artículos cargados.
Mi problema es la ventana de consulta que muestra específicamente ciertos datos.


Este es mi código, si alguien me puede dar una mano por favor. Tengo un examen pronto y la verdad que eso me esta complicando la vida.

https://www.mediafire.com/?6tzn3g25uhv07fu



Main Class
Código
  1. ]public class Clase14Quiosco {
  2.  
  3.  
  4.    public static void main(String[] args) {
  5.        MenuPrincipal v = new MenuPrincipal();
  6.        v.setVisible(true);
  7.    }
  8.  
  9. }
  10.  
  11.  



MenuPrincipal class
Código
  1. import java.util.ArrayList;
  2. import javax.swing.JOptionPane;
  3.  
  4.  
  5. public class MenuPrincipal extends javax.swing.JFrame {
  6.  
  7.    private ArrayList<Articulo> listaArticulos;
  8.  
  9.  
  10.    public MenuPrincipal() {
  11.        initComponents();
  12.        listaArticulos = new ArrayList<>();
  13.    }
  14.  
  15.  
  16.    private void initComponents() {
  17.  
  18.        jMenuBar1 = new javax.swing.JMenuBar();
  19.        jMenu1 = new javax.swing.JMenu();
  20.        jMenuItem1 = new javax.swing.JMenuItem();
  21.        jMenu2 = new javax.swing.JMenu();
  22.        jMenuItem2 = new javax.swing.JMenuItem();
  23.  
  24.        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  25.  
  26.        jMenu1.setText("Articulos");
  27.        jMenu1.addActionListener(new java.awt.event.ActionListener() {
  28.            public void actionPerformed(java.awt.event.ActionEvent evt) {
  29.                jMenu1ActionPerformed(evt);
  30.            }
  31.        });
  32.  
  33.        jMenuItem1.setText("Alta");
  34.        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
  35.            public void actionPerformed(java.awt.event.ActionEvent evt) {
  36.                jMenuItem1ActionPerformed(evt);
  37.            }
  38.        });
  39.        jMenu1.add(jMenuItem1);
  40.  
  41.        jMenuBar1.add(jMenu1);
  42.  
  43.        jMenu2.setText("Reportes");
  44.  
  45.        jMenuItem2.setText("Listado");
  46.        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
  47.            public void actionPerformed(java.awt.event.ActionEvent evt) {
  48.                jMenuItem2ActionPerformed(evt);
  49.            }
  50.        });
  51.        jMenu2.add(jMenuItem2);
  52.  
  53.        jMenuBar1.add(jMenu2);
  54.  
  55.        setJMenuBar(jMenuBar1);
  56.  
  57.        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  58.        getContentPane().setLayout(layout);
  59.        layout.setHorizontalGroup(
  60.            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  61.            .addGap(0, 400, Short.MAX_VALUE)
  62.        );
  63.        layout.setVerticalGroup(
  64.            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  65.            .addGap(0, 279, Short.MAX_VALUE)
  66.        );
  67.  
  68.        pack();
  69.    }// </editor-fold>                        
  70.  
  71.    private void jMenu1ActionPerformed(java.awt.event.ActionEvent evt) {                                      
  72.  
  73.    }                                      
  74.  
  75.    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {                                          
  76.        AltaArticulo v = new AltaArticulo(listaArticulos);
  77.        v.setVisible(true);
  78.    }                                          
  79.  
  80.    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {                                          
  81.        ConsultaArticulos v = new ConsultaArticulos(listaArticulos);
  82.        v.setVisible(true);
  83.    }                                          
  84.  
  85.  
  86.    // Variables declaration - do not modify                    
  87.    private javax.swing.JMenu jMenu1;
  88.    private javax.swing.JMenu jMenu2;
  89.    private javax.swing.JMenuBar jMenuBar1;
  90.    private javax.swing.JMenuItem jMenuItem1;
  91.    private javax.swing.JMenuItem jMenuItem2;
  92.    // End of variables declaration                  
  93. }
  94.  
  95.  


AltaArticulo class
Código
  1. import java.util.ArrayList;
  2. import javax.swing.JOptionPane;
  3.  
  4.  
  5. public class AltaArticulo extends javax.swing.JFrame {
  6.  
  7.    private ArrayList<Articulo> listaArticulos;
  8.  
  9.    public AltaArticulo() {
  10.        initComponents();
  11.    }
  12.  
  13.    public AltaArticulo(ArrayList<Articulo> listaArticulos) {
  14.        initComponents();
  15.        this.listaArticulos = listaArticulos;
  16.    }
  17.  
  18.  
  19.    private void initComponents() {
  20.  
  21.        jLabel1 = new javax.swing.JLabel();
  22.        jLabel2 = new javax.swing.JLabel();
  23.        jLabel3 = new javax.swing.JLabel();
  24.        jLabel4 = new javax.swing.JLabel();
  25.        jLabel5 = new javax.swing.JLabel();
  26.        jLabel6 = new javax.swing.JLabel();
  27.        txtCodigo = new javax.swing.JTextField();
  28.        txtNombre = new javax.swing.JTextField();
  29.        txtPrecio = new javax.swing.JTextField();
  30.        txtStockActual = new javax.swing.JTextField();
  31.        txtStockMinimo = new javax.swing.JTextField();
  32.        cboCategoria = new javax.swing.JComboBox();
  33.        btnAgregar = new javax.swing.JButton();
  34.  
  35.        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
  36.  
  37.        jLabel1.setText("Codigo");
  38.  
  39.        jLabel2.setText("Nombre");
  40.  
  41.        jLabel3.setText("Precio");
  42.  
  43.        jLabel4.setText("Stock actual");
  44.  
  45.        jLabel5.setText("Stock mínimo");
  46.  
  47.        jLabel6.setText("Categoria");
  48.  
  49.        txtCodigo.addActionListener(new java.awt.event.ActionListener() {
  50.            public void actionPerformed(java.awt.event.ActionEvent evt) {
  51.                txtCodigoActionPerformed(evt);
  52.            }
  53.        });
  54.  
  55.        cboCategoria.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Almacen", "Perfumeria", "Otros" }));
  56.  
  57.        btnAgregar.setText("Agregar");
  58.        btnAgregar.addActionListener(new java.awt.event.ActionListener() {
  59.            public void actionPerformed(java.awt.event.ActionEvent evt) {
  60.                btnAgregarActionPerformed(evt);
  61.            }
  62.        });
  63.  
  64.        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  65.        getContentPane().setLayout(layout);
  66.        layout.setHorizontalGroup(
  67.            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  68.            .addGroup(layout.createSequentialGroup()
  69.                .addGap(46, 46, 46)
  70.                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
  71.                    .addComponent(jLabel2)
  72.                    .addComponent(jLabel1)
  73.                    .addComponent(jLabel6)
  74.                    .addComponent(jLabel5)
  75.                    .addComponent(jLabel3)
  76.                    .addComponent(jLabel4))
  77.                .addGap(18, 18, 18)
  78.                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
  79.                    .addComponent(btnAgregar)
  80.                    .addComponent(cboCategoria, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  81.                    .addComponent(txtCodigo)
  82.                    .addComponent(txtNombre)
  83.                    .addComponent(txtPrecio)
  84.                    .addComponent(txtStockActual)
  85.                    .addComponent(txtStockMinimo))
  86.                .addContainerGap(41, Short.MAX_VALUE))
  87.        );
  88.        layout.setVerticalGroup(
  89.            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  90.            .addGroup(layout.createSequentialGroup()
  91.                .addGap(26, 26, 26)
  92.                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  93.                    .addComponent(txtCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  94.                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
  95.                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  96.                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  97.                    .addComponent(txtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  98.                    .addComponent(jLabel2))
  99.                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  100.                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  101.                    .addComponent(txtPrecio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  102.                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
  103.                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  104.                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  105.                    .addComponent(txtStockActual, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  106.                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
  107.                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  108.                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  109.                    .addComponent(txtStockMinimo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  110.                    .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
  111.                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  112.                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  113.                    .addComponent(cboCategoria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
  114.                    .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
  115.                .addGap(18, 18, 18)
  116.                .addComponent(btnAgregar)
  117.                .addContainerGap(24, Short.MAX_VALUE))
  118.        );
  119.  
  120.        pack();
  121.    }// </editor-fold>                        
  122.  
  123.    private void btnAgregarActionPerformed(java.awt.event.ActionEvent evt) {                                          
  124.        int codigo = Integer.parseInt(txtCodigo.getText());
  125.        String nombre = txtNombre.getText();
  126.        float precio = Float.parseFloat(txtPrecio.getText());
  127.        int stockActual = Integer.parseInt(txtStockActual.getText());
  128.        int stockMinimo = Integer.parseInt(txtStockMinimo.getText());
  129.        int categoria = cboCategoria.getSelectedIndex()+1;
  130.  
  131.        Articulo nuevo = new Articulo();
  132.  
  133.        nuevo.setCodigo(codigo);
  134.        nuevo.setNombre(nombre);
  135.        nuevo.setPrecio(precio);
  136.        nuevo.setStockActual(stockActual);
  137.        nuevo.setStockMinimo(stockMinimo);
  138.        nuevo.setCategoria(categoria);
  139.  
  140.        listaArticulos.add(nuevo);
  141.  
  142.        JOptionPane.showMessageDialog(this, listaArticulos.toString());
  143.    }                                          
  144.  
  145.    private void txtCodigoActionPerformed(java.awt.event.ActionEvent evt) {                                          
  146.        // TODO add your handling code here:
  147.    }                                        
  148.  
  149.  
  150.    public static void main(String args[]) {
  151.  
  152.  
  153.        try {
  154.            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  155.                if ("Nimbus".equals(info.getName())) {
  156.                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
  157.                    break;
  158.                }
  159.            }
  160.        } catch (ClassNotFoundException ex) {
  161.            java.util.logging.Logger.getLogger(AltaArticulo.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  162.        } catch (InstantiationException ex) {
  163.            java.util.logging.Logger.getLogger(AltaArticulo.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  164.        } catch (IllegalAccessException ex) {
  165.            java.util.logging.Logger.getLogger(AltaArticulo.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  166.        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  167.            java.util.logging.Logger.getLogger(AltaArticulo.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  168.        }
  169.        //</editor-fold>
  170.  
  171.  
  172.        java.awt.EventQueue.invokeLater(new Runnable() {
  173.            public void run() {
  174.                new AltaArticulo().setVisible(true);
  175.            }
  176.        });
  177.    }
  178.  
  179.    // Variables declaration - do not modify                    
  180.    private javax.swing.JButton btnAgregar;
  181.    private javax.swing.JComboBox cboCategoria;
  182.    private javax.swing.JLabel jLabel1;
  183.    private javax.swing.JLabel jLabel2;
  184.    private javax.swing.JLabel jLabel3;
  185.    private javax.swing.JLabel jLabel4;
  186.    private javax.swing.JLabel jLabel5;
  187.    private javax.swing.JLabel jLabel6;
  188.    private javax.swing.JTextField txtCodigo;
  189.    private javax.swing.JTextField txtNombre;
  190.    private javax.swing.JTextField txtPrecio;
  191.    private javax.swing.JTextField txtStockActual;
  192.    private javax.swing.JTextField txtStockMinimo;
  193.    // End of variables declaration                  
  194. }
  195.  
  196.  




ConsultaArticulos class

Código
  1. import java.util.ArrayList;
  2.  
  3. public class ConsultaArticulos extends javax.swing.JFrame {
  4.  
  5.  
  6.    public ConsultaArticulos() {
  7.        initComponents();
  8.    }
  9.  
  10.    public ConsultaArticulos(ArrayList<Articulo> listaArticulos) {
  11.        initComponents();
  12.        lstArticulos.setListData(listaArticulos.toArray());
  13.    }
  14.  
  15.    private void initComponents() {
  16.  
  17.        jScrollPane1 = new javax.swing.JScrollPane();
  18.        lstArticulos = new javax.swing.JList();
  19.  
  20.        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
  21.  
  22.        jScrollPane1.setViewportView(lstArticulos);
  23.  
  24.        getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);
  25.  
  26.        pack();
  27.    }// </editor-fold>                        
  28.  
  29.  
  30.    public static void main(String args[]) {
  31.  
  32.        try {
  33.            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
  34.                if ("Nimbus".equals(info.getName())) {
  35.                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
  36.                    break;
  37.                }
  38.            }
  39.        } catch (ClassNotFoundException ex) {
  40.            java.util.logging.Logger.getLogger(ConsultaArticulos.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  41.        } catch (InstantiationException ex) {
  42.            java.util.logging.Logger.getLogger(ConsultaArticulos.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  43.        } catch (IllegalAccessException ex) {
  44.            java.util.logging.Logger.getLogger(ConsultaArticulos.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  45.        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
  46.            java.util.logging.Logger.getLogger(ConsultaArticulos.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
  47.        }
  48.        //</editor-fold>
  49.  
  50.  
  51.        java.awt.EventQueue.invokeLater(new Runnable() {
  52.            public void run() {
  53.                new ConsultaArticulos().setVisible(true);
  54.            }
  55.        });
  56.    }
  57.  
  58.    // Variables declaration - do not modify                    
  59.    private javax.swing.JScrollPane jScrollPane1;
  60.    private javax.swing.JList lstArticulos;
  61.    // End of variables declaration                  
  62. }
  63.  
  64.  



Articulo class
Código
  1. public class Articulo {
  2.    private int codigo;
  3.    private String nombre;
  4.    private float precio;
  5.    private int stockActual;
  6.    private int stockMinimo;
  7.    private int categoria;
  8.  
  9.    public Articulo() {
  10.    }
  11.  
  12.    public int getCodigo() {
  13.        return codigo;
  14.    }
  15.  
  16.    public void setCodigo(int codigo) {
  17.        this.codigo = codigo;
  18.    }
  19.  
  20.    public String getNombre() {
  21.        return nombre;
  22.    }
  23.  
  24.    public void setNombre(String nombre) {
  25.        this.nombre = nombre;
  26.    }
  27.  
  28.    public float getPrecio() {
  29.        return precio;
  30.    }
  31.  
  32.    public void setPrecio(float precio) {
  33.        this.precio = precio;
  34.    }
  35.  
  36.    public int getStockActual() {
  37.        return stockActual;
  38.    }
  39.  
  40.    public void setStockActual(int stockActual) {
  41.        this.stockActual = stockActual;
  42.    }
  43.  
  44.    public int getStockMinimo() {
  45.        return stockMinimo;
  46.    }
  47.  
  48.    public void setStockMinimo(int stockMinimo) {
  49.        this.stockMinimo = stockMinimo;
  50.    }
  51.  
  52.    public int getCategoria() {
  53.        return categoria;
  54.    }
  55.  
  56.    public void setCategoria(int categoria) {
  57.        this.categoria = categoria;
  58.    }
  59.  
  60.    @Override
  61.    public String toString() {
  62.        return "Articulo{" + "codigo=" + codigo + ", nombre=" + nombre + ", precio=" + precio + ", stockActual=" + stockActual + ", stockMinimo=" + stockMinimo + ", categoria=" + categoria + '}';
  63.    }
  64.  
  65. }
  66.  
  67.  
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines