Untitled

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

import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.SwingConstants;

public class configurarCuotaDiaria extends JFrame implements ActionListener{

	private static final long serialVersionUID = 1L;
	private JPanel contentPane;
	private JTextField textCuotaDiaria;
	private JButton btnAceptarCdiaria;
	private JButton btnCancelarCdiaria;
	
	public static double cuotaDiaria = 75000.0;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					configurarCuotaDiaria frame = new configurarCuotaDiaria();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public configurarCuotaDiaria() {
		setTitle("Configurar Cuota Diaria");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 143);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));

		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel lblNewLabel = new JLabel("Cuota diaria esperada (S/)");
		lblNewLabel.setBounds(28, 30, 165, 14);
		contentPane.add(lblNewLabel);
		
		textCuotaDiaria = new JTextField("" + cuotaDiaria);
		textCuotaDiaria.setHorizontalAlignment(SwingConstants.RIGHT);
		textCuotaDiaria.setBounds(203, 27, 86, 20);
		contentPane.add(textCuotaDiaria);
		textCuotaDiaria.setColumns(10);
		
		btnAceptarCdiaria = new JButton("Aceptar");
		btnAceptarCdiaria.setBounds(314, 26, 89, 23);
		btnAceptarCdiaria.addActionListener(this);
		contentPane.add(btnAceptarCdiaria);
		
		btnCancelarCdiaria = new JButton("Cancelar");
		btnCancelarCdiaria.setBounds(314, 60, 89, 23);
		btnCancelarCdiaria.addActionListener(this);
		contentPane.add(btnCancelarCdiaria);
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		
		if (e.getSource() == btnAceptarCdiaria) {
			cuotaDiaria = Double.parseDouble(textCuotaDiaria.getText());
			JOptionPane.showMessageDialog(null, "Cambio Realizado con Éxito", "Aviso", JOptionPane.INFORMATION_MESSAGE);
			dispose();
		}
		if (e.getSource() == btnCancelarCdiaria) {
			dispose();
		}
	}
}
Leave a Comment