Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
3.9 kB
1
Indexable
Never
package sistemaCocinas;

import java.awt.EventQueue;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.UIManager;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class configurarObsequio extends JDialog implements ActionListener {

    private static final long serialVersionUID = 1L;
    private JLabel lblNewLabel;
    private JLabel lblUnidad;
    private JLabel lblAMs;
    private JTextField textObsequio1;
    private JTextField textObsequio2;
    private JTextField textObsequio3;
    private JButton btnCancelar;
    private JButton btnAceptar;
    public static String obsequio1 = "Cafetera";
    public static String obsequio2 = "Licuadora";
    public static String obsequio3 = "Extractor";
    
    public static void main(String[] args) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Throwable e) {
            e.printStackTrace();
        }
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                	configurarObsequio dialog = new configurarObsequio();
                    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
                    dialog.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    public configurarObsequio() {
        setTitle("Configurar Obsequios");
        setResizable(false);
        setModal(true);
        setBounds(100, 100, 418, 126);
        getContentPane().setLayout(null);

        lblNewLabel = new JLabel("1 unidad");
        lblNewLabel.setBounds(20, 11, 103, 14);
        getContentPane().add(lblNewLabel);

        lblUnidad = new JLabel("2 a 5 unidades");
        lblUnidad.setBounds(20, 36, 103, 14);
        getContentPane().add(lblUnidad);

        lblAMs = new JLabel("6 a más unidades");
        lblAMs.setBounds(20, 61, 103, 14);
        getContentPane().add(lblAMs);

        textObsequio1 = new JTextField(obsequio1);
        textObsequio1.setBounds(133, 8, 86, 20);
        getContentPane().add(textObsequio1);
        textObsequio1.setColumns(10);

        textObsequio2 = new JTextField(obsequio2);
        textObsequio2.setColumns(10);
        textObsequio2.setBounds(133, 33, 86, 20);
        getContentPane().add(textObsequio2);
        
        textObsequio3 = new JTextField(obsequio3);
        textObsequio3.setBounds(133, 58, 86, 20);
        getContentPane().add(textObsequio3);
        textObsequio3.setColumns(10);

        btnCancelar = new JButton("Cancelar");
        btnCancelar.addActionListener(this);
        btnCancelar.setBounds(298, 36, 89, 23);
        getContentPane().add(btnCancelar);

        btnAceptar = new JButton("Aceptar");
        btnAceptar.addActionListener(this);
        btnAceptar.setBounds(298, 7, 89, 23);
        getContentPane().add(btnAceptar);
    }

    public void actionPerformed(ActionEvent e) {
    	    	   	
    	if (e.getSource() == btnAceptar) {
            actionPerformedBtnAceptar(e);
        }
        if (e.getSource() == btnCancelar) {
            actionPerformedBtnCancelar(e);
        }
    }

    protected void actionPerformedBtnCancelar(ActionEvent e) {
        dispose();
    }

    protected void actionPerformedBtnAceptar(ActionEvent e) {
    	
    	obsequio1 = textObsequio1.getText();
    	obsequio2 = textObsequio2.getText();
    	obsequio3 = textObsequio3.getText();
    	
        JOptionPane.showMessageDialog(null, "Cambio Realizado con Éxito", "Aviso", JOptionPane.INFORMATION_MESSAGE);
        dispose();
    }
}
Leave a Comment