|
| 1 | +package giis.demo.tkrun; |
| 2 | + |
| 3 | +import javax.swing.JFrame; |
| 4 | +import net.miginfocom.swing.MigLayout; |
| 5 | +import javax.swing.JLabel; |
| 6 | +import javax.swing.JOptionPane; |
| 7 | +import javax.swing.JTextField; |
| 8 | +import javax.swing.JButton; |
| 9 | + |
| 10 | +import javax.swing.JPanel; |
| 11 | +import java.awt.Font; |
| 12 | +import java.awt.FlowLayout; |
| 13 | +import java.awt.Color; |
| 14 | + |
| 15 | +public class EmpresaView { |
| 16 | + |
| 17 | + private JFrame frmRegistroEmpresa; |
| 18 | + private JLabel lbTítulo; |
| 19 | + private JTextField tfNombre; |
| 20 | + private JPanel pnEmisor; |
| 21 | + private JLabel lbNombre; |
| 22 | + private JButton btnCancelar; |
| 23 | + private JButton btRegistro; |
| 24 | + |
| 25 | + /** |
| 26 | + * Create the application. |
| 27 | + */ |
| 28 | + public EmpresaView() { |
| 29 | + initialize(); |
| 30 | + } |
| 31 | + |
| 32 | + /** |
| 33 | + * Initialize the contents of the frame. |
| 34 | + */ |
| 35 | + private void initialize() { |
| 36 | + frmRegistroEmpresa = new JFrame(); |
| 37 | + frmRegistroEmpresa.setTitle("RegistroEmpresa"); |
| 38 | + frmRegistroEmpresa.setName("RegistroEmpresa"); |
| 39 | + frmRegistroEmpresa.setBounds(0, 0, 301, 155); |
| 40 | + frmRegistroEmpresa.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); |
| 41 | + frmRegistroEmpresa.getContentPane().setLayout(new MigLayout("", "[grow]", "[][][][]")); |
| 42 | + |
| 43 | + lbTítulo = new JLabel("Registro de envíos de empresa:"); |
| 44 | + lbTítulo.setFont(new Font("Tahoma", Font.BOLD, 15)); |
| 45 | + frmRegistroEmpresa.getContentPane().add(lbTítulo, "cell 0 0"); |
| 46 | + |
| 47 | + pnEmisor = new JPanel(); |
| 48 | + FlowLayout flowLayout = (FlowLayout) pnEmisor.getLayout(); |
| 49 | + flowLayout.setAlignment(FlowLayout.LEFT); |
| 50 | + frmRegistroEmpresa.getContentPane().add(pnEmisor, "cell 0 2,grow"); |
| 51 | + |
| 52 | + lbNombre = new JLabel("Nombre de la empresa:"); |
| 53 | + lbNombre.setFont(new Font("Tahoma", Font.PLAIN, 13)); |
| 54 | + pnEmisor.add(lbNombre); |
| 55 | + |
| 56 | + tfNombre = new JTextField(); |
| 57 | + pnEmisor.add(tfNombre); |
| 58 | + tfNombre.setColumns(10); |
| 59 | + |
| 60 | + JPanel pnBotones = new JPanel(); |
| 61 | + FlowLayout fl_pnBotones = (FlowLayout) pnBotones.getLayout(); |
| 62 | + fl_pnBotones.setAlignment(FlowLayout.RIGHT); |
| 63 | + frmRegistroEmpresa.getContentPane().add(pnBotones, "cell 0 3,grow"); |
| 64 | + |
| 65 | + btnCancelar = new JButton("Cancelar"); |
| 66 | + btnCancelar.setForeground(Color.WHITE); |
| 67 | + btnCancelar.setBackground(Color.RED); |
| 68 | + btnCancelar.setFont(new Font("Tahoma", Font.BOLD, 12)); |
| 69 | + pnBotones.add(btnCancelar); |
| 70 | + |
| 71 | + btRegistro = new JButton("Registrar envíos"); |
| 72 | + btRegistro.setBackground(Color.GREEN); |
| 73 | + btRegistro.setFont(new Font("Tahoma", Font.BOLD, 12)); |
| 74 | + pnBotones.add(btRegistro); |
| 75 | + } |
| 76 | + |
| 77 | + public void reset() { |
| 78 | + this.tfNombre.setText(""); |
| 79 | + this.getFrame().setVisible(false); |
| 80 | + |
| 81 | + } |
| 82 | + |
| 83 | + //Getters y Setters anyadidos para acceso desde el controlador (repersentacion compacta) |
| 84 | + public JFrame getFrame() { return this.frmRegistroEmpresa; } |
| 85 | + public JButton getBtCancelar() { return this.btnCancelar; } |
| 86 | + public JButton getBtRegistrar() { return this.btRegistro; } |
| 87 | + public JTextField getTfNombreE() { return tfNombre; } |
| 88 | + |
| 89 | + public boolean comprobarCampos() { |
| 90 | + if(this.tfNombre.getText().isBlank()) { |
| 91 | + JOptionPane.showMessageDialog(null, "Rellena con el nombre de la empresa"); |
| 92 | + return false; |
| 93 | + } |
| 94 | + return true; |
| 95 | + } |
| 96 | +} |
0 commit comments