Documento importante no. III
Documento importante no. III
Documento importante no. III
java
package login;
import javax.swing.JOptionPane;
import javax.swing.plaf.OptionPaneUI;
import javax.swing.table.DefaultTableModel;
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jMenuItem1.setText("jMenuItem1");
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
));
jScrollPane1.setViewportView(jTable1);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("Tienda electronica");
jLabel2.setText("Producto");
jLabel3.setText("Precio");
jLabel4.setText("Cantidad");
Precio.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
PrecioActionPerformed(evt);
}
});
Limpiar.setText("Limpiar");
Limpiar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
LimpiarActionPerformed(evt);
}
});
mt.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Producto", "Precio", "Cantidad", "Subtotal"
}
));
jScrollPane2.setViewportView(mt);
jLabel5.setText("Detalles de la compra");
jLabel6.setText("Total:");
lblTotal.setText("0.0");
Borrar.setText("Borrar producto");
Borrar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
BorrarActionPerformed(evt);
}
});
Agregar.setText("Agregar compra");
Agregar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
AgregarActionPerformed(evt);
}
});
Terminar.setText("Terminar compra");
Terminar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
TerminarActionPerformed(evt);
}
});
jMenu1.setText("Archivo");
Cerrar.setText("Salir");
Cerrar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CerrarActionPerformed(evt);
}
});
jMenu1.add(Cerrar);
jMenuBar1.add(jMenu1);
jMenu2.setText("Editar");
jMenuBar1.add(jMenu2);
setJMenuBar(jMenuBar1);
pack();
}// </editor-fold>
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Tienda.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Tienda.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Tienda.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Tienda.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//</editor-fold>
Método.java
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package login;
import java.util.ArrayList;
/**
*
* @author Ufinal
*/
public class Metodo {
public Metodo() {
}
login.java
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
*/
package login;
import javax.swing.JOptionPane;
/**
*
* @author Chris
*/
public class login extends javax.swing.JFrame {
/**
* Creates new form login
*/
public login() {
initComponents();
this.setLocationRelativeTo(null);
this.setTitle("Iniciar Sesion");
}
public void Cancelar(){
Usuario.setText("");
Pass.setText("");
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jButton3.setText("jButton3");
jMenuItem1.setText("jMenuItem1");
jMenuItem2.setText("jMenuItem2");
jMenuItem3.setText("jMenuItem3");
jMenuItem4.setText("jMenuItem4");
jMenuItem5.setText("jMenuItem5");
jMenuItem6.setText("jMenuItem6");
jMenuItem7.setText("jMenuItem7");
jMenuItem8.setText("jMenuItem8");
jMenuItem9.setText("jMenuItem9");
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("Usuario");
jLabel2.setText("Contraseña");
Aceptar.setText("Aceptar");
Aceptar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
AceptarActionPerformed(evt);
}
});
Cancelar.setText("Cancelar");
Cancelar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
CancelarActionPerformed(evt);
}
});
jMenu1.setText("Archivo");
Salir.setText("Salir");
Salir.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
SalirActionPerformed(evt);
}
});
jMenu1.add(Salir);
jMenuBar1.add(jMenu1);
jMenu2.setText("Editar");
jMenuBar1.add(jMenu2);
setJMenuBar(jMenuBar1);
pack();
}// </editor-fold>
if(usuario.isEmpty() || contrasena.isEmpty()){
JOptionPane.showMessageDialog(null, "Complete todos los campos", "ERROR",
JOptionPane.ERROR_MESSAGE);
}else{
if(usuario.equals("Chris")&& contrasena.equals("1234")){
Tienda shop=new Tienda();
shop.setVisible(true);
shop.setTitle("Bienvenido :D " +usuario);
shop.setLocationRelativeTo(null);
this.setVisible(false);
}else{
if(usuario.equals("Hanita")&& contrasena.equals("chocolate")){
Tienda shop=new Tienda();
shop.setVisible(true);
shop.setTitle("Bienvenida :D " +usuario);
shop.setLocationRelativeTo(null);
this.setVisible(false);
}else{
JOptionPane.showMessageDialog(null, "El usuario y/o contraseña son incorrectos");
}
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
}
//</editor-fold>