Está en la página 1de 3

package ejemplo1; /* * To change this template, choose Tools | Templates * and open the template in the editor.

*/ /** * * @author Administrador */ import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.sql.*; public class Facturacion extends JFrame implements ActionListener { private JTextField jtnumfactura; private JTextField jtidcliente; private JTextField jtclaveproducto; private JTextField jtcantidad; private JTextField jttotal; private private private private private JLabel JLabel JLabel JLabel JLabel jlnumfactura; jlidcliente; jlclaveproducto; jlcantidad; jltotal;

private JButton jbagregar; private JButton jbcrearfacrura; private JTextArea jtaMostrar; private JScrollPane jsDeslizante; public void crearGUI(){ setDefaultCloseOperation(EXIT_ON_CLOSE); Container ventana = getContentPane(); ventana.setLayout(null); jlnumfactura = new JLabel("numero de factura"); ventana.add(jlnumfactura); jlnumfactura.setBounds(20,20,140,20); jlidcliente = new JLabel("id cliente"); ventana.add(jlidcliente); jlidcliente.setBounds(20,50,100,20); jlclaveproducto= new JLabel("clave producto"); ventana.add(jlclaveproducto); jlclaveproducto.setBounds(20,80,100,20); jlcantidad= new JLabel("cantidad"); ventana.add(jlcantidad); jlcantidad.setBounds(20,110,100,20); jltotal= new JLabel("total"); ventana.add(jltotal); jltotal.setBounds(20,140,100,20);

jtnumfactura = new JTextField(); ventana.add(jtnumfactura); jtnumfactura.setBounds(160,20,100,20); jtidcliente = new JTextField(); ventana.add(jtidcliente); jtidcliente.setBounds(160,50,100,20); jtclaveproducto = new JTextField(); ventana.add(jtclaveproducto); jtclaveproducto.setBounds(160,80,100,20); jtcantidad = new JTextField(); ventana.add(jtcantidad); jtcantidad.setBounds(160,110,100,20); jttotal = new JTextField(); ventana.add(jttotal); jttotal.setBounds(160,140,100,20); jbagregar = new JButton("agregar"); ventana.add(jbagregar); jbagregar.setBounds(400,50,80,20); jbagregar.addActionListener(this); jbcrearfacrura = new JButton("crear factura"); ventana.add(jbcrearfacrura); jbcrearfacrura.setBounds(400,120,140,20); jbcrearfacrura.addActionListener(this); jtaMostrar = new JTextArea(); jsDeslizante = new JScrollPane (jtaMostrar); ventana.add(jsDeslizante); jsDeslizante.setBounds(20,200,400,200); } public void actionPerformed(ActionEvent evt){ Object evento = evt.getSource(); String id = jtnumfactura.getText(); String Nombre = jtidcliente.getText(); conectafactura conectar = new conectafactura(); jtaMostrar.setText("ID\tNOMBRE\n"); if(evento==jbagregar); conectar.conectafactura(); jtaMostrar.append(conectar.Insertar(id,Nombre)); { } if(evento==jbcrearfacrura){ conectar.conectafactura(); jtaMostrar.append(conectar.Eliminar(id)); } } public static void main (String[] args){

Facturacion marco = new Facturacion (); marco.setTitle("factura"); marco.setSize(600,500); marco.crearGUI();; marco.setVisible(true); } }

También podría gustarte