|
| 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.JTextField; |
| 7 | +import javax.swing.JButton; |
| 8 | + |
| 9 | +import javax.swing.JPanel; |
| 10 | +import java.awt.Font; |
| 11 | +import java.awt.FlowLayout; |
| 12 | +import java.awt.Color; |
| 13 | +import javax.swing.JScrollPane; |
| 14 | +import javax.swing.JTable; |
| 15 | + |
| 16 | +/** |
| 17 | + * Vista de la pantalla que muestra las carreras activas y permite interactuar con ellas. |
| 18 | + * <br/>Se ha generado con WindowBulder y modificado para ser conforme a MVC teniendo en cuenta: |
| 19 | + * - Se elimina main (es invocada desde CarrerasMain) y se incluye Title en el frame |
| 20 | + * - No se incluye ningun handler de eventos pues estos van en el controlador |
| 21 | + * - Las tablas se encierran en JOptionPane para que se puedan visualizar las cabeceras |
| 22 | + * - Se asinga nombre a las tablas si se van a automatizar la ejecucion de pruebas |
| 23 | + * - Incluye al final los metodos adicionales necesarios para acceder al UI desde el controlador |
| 24 | + */ |
| 25 | +public class LocalizacionEnvioView { |
| 26 | + |
| 27 | + private JFrame frmTransportista; |
| 28 | + private JLabel lbTítulo; |
| 29 | + private JTextField tfNRef; |
| 30 | + private JPanel pnEnvio; |
| 31 | + private JLabel lbNRef; |
| 32 | + private JButton btnSalir; |
| 33 | + private JButton btBuscar; |
| 34 | + private JScrollPane pnMovimientos; |
| 35 | + private JTable tbMovimientos; |
| 36 | + private JLabel lbEstado; |
| 37 | + private JTextField tfEstado; |
| 38 | + private JLabel lbInfo; |
| 39 | + private JScrollPane pnInfo; |
| 40 | + private JTable tbInfo; |
| 41 | + private JLabel lbMovimientos; |
| 42 | + |
| 43 | + /** |
| 44 | + * Create the application. |
| 45 | + */ |
| 46 | + public LocalizacionEnvioView() { |
| 47 | + initialize(); |
| 48 | + } |
| 49 | + |
| 50 | + /** |
| 51 | + * Initialize the contents of the frame. |
| 52 | + */ |
| 53 | + private void initialize() { |
| 54 | + frmTransportista = new JFrame(); |
| 55 | + frmTransportista.setTitle("EnvíosTransportista"); |
| 56 | + frmTransportista.setName("EnvíosTransportista"); |
| 57 | + frmTransportista.setBounds(0, 0, 577, 438); |
| 58 | + frmTransportista.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); |
| 59 | + frmTransportista.getContentPane().setLayout(new MigLayout("", "[grow]", "[][][][][][grow][][grow][][]")); |
| 60 | + |
| 61 | + lbTítulo = new JLabel("Localización de un envío:"); |
| 62 | + lbTítulo.setFont(new Font("Tahoma", Font.BOLD, 15)); |
| 63 | + frmTransportista.getContentPane().add(lbTítulo, "cell 0 0"); |
| 64 | + |
| 65 | + pnEnvio = new JPanel(); |
| 66 | + FlowLayout fl_pnEnvio = (FlowLayout) pnEnvio.getLayout(); |
| 67 | + fl_pnEnvio.setAlignment(FlowLayout.LEFT); |
| 68 | + frmTransportista.getContentPane().add(pnEnvio, "cell 0 2,grow"); |
| 69 | + |
| 70 | + lbNRef = new JLabel("Número de referencia del envío: "); |
| 71 | + lbNRef.setFont(new Font("Tahoma", Font.PLAIN, 13)); |
| 72 | + pnEnvio.add(lbNRef); |
| 73 | + |
| 74 | + tfNRef = new JTextField(); |
| 75 | + pnEnvio.add(tfNRef); |
| 76 | + tfNRef.setColumns(10); |
| 77 | + |
| 78 | + btBuscar = new JButton("Buscar envío"); |
| 79 | + btBuscar.setFont(new Font("Tahoma", Font.BOLD, 12)); |
| 80 | + btBuscar.setBackground(Color.GREEN); |
| 81 | + pnEnvio.add(btBuscar); |
| 82 | + |
| 83 | + lbEstado = new JLabel("El envío se encuentra en el estado: "); |
| 84 | + lbEstado.setFont(new Font("Tahoma", Font.PLAIN, 13)); |
| 85 | + frmTransportista.getContentPane().add(lbEstado, "flowx,cell 0 3"); |
| 86 | + |
| 87 | + lbInfo = new JLabel("Información general del envío:"); |
| 88 | + lbInfo.setFont(new Font("Tahoma", Font.PLAIN, 13)); |
| 89 | + frmTransportista.getContentPane().add(lbInfo, "cell 0 4"); |
| 90 | + |
| 91 | + pnInfo = new JScrollPane(); |
| 92 | + frmTransportista.getContentPane().add(pnInfo, "cell 0 5,grow"); |
| 93 | + |
| 94 | + tbInfo = new JTable(); |
| 95 | + tbInfo.setDefaultEditor(Object.class, null); //readonly |
| 96 | + pnInfo.setViewportView(tbInfo); |
| 97 | + |
| 98 | + lbMovimientos = new JLabel("Movimientos del envío:"); |
| 99 | + lbMovimientos.setFont(new Font("Tahoma", Font.PLAIN, 13)); |
| 100 | + frmTransportista.getContentPane().add(lbMovimientos, "cell 0 6"); |
| 101 | + |
| 102 | + pnMovimientos = new JScrollPane(); |
| 103 | + frmTransportista.getContentPane().add(pnMovimientos, "cell 0 7,grow"); |
| 104 | + |
| 105 | + tbMovimientos = new JTable(); |
| 106 | + tbMovimientos.setDefaultEditor(Object.class, null); //readonly |
| 107 | + pnMovimientos.setViewportView(tbMovimientos); |
| 108 | + |
| 109 | + JPanel pnSalir = new JPanel(); |
| 110 | + FlowLayout fl_pnSalir = (FlowLayout) pnSalir.getLayout(); |
| 111 | + fl_pnSalir.setAlignment(FlowLayout.RIGHT); |
| 112 | + frmTransportista.getContentPane().add(pnSalir, "cell 0 9,grow"); |
| 113 | + |
| 114 | + btnSalir = new JButton("Salir"); |
| 115 | + btnSalir.setForeground(Color.WHITE); |
| 116 | + btnSalir.setBackground(Color.RED); |
| 117 | + btnSalir.setFont(new Font("Tahoma", Font.BOLD, 12)); |
| 118 | + pnSalir.add(btnSalir); |
| 119 | + |
| 120 | + tfEstado = new JTextField(); |
| 121 | + tfEstado.setFont(new Font("Tahoma", Font.BOLD, 13)); |
| 122 | + tfEstado.setEditable(false); |
| 123 | + frmTransportista.getContentPane().add(tfEstado, "cell 0 3"); |
| 124 | + tfEstado.setColumns(10); |
| 125 | + } |
| 126 | + |
| 127 | + public void reset() { |
| 128 | + this.tfNRef.setText(""); |
| 129 | + this.getFrame().setVisible(false); |
| 130 | + |
| 131 | + } |
| 132 | + |
| 133 | + //Getters y Setters anyadidos para acceso desde el controlador (repersentacion compacta) |
| 134 | + public JFrame getFrame() { return this.frmTransportista; } |
| 135 | + public JButton getBtSalir() { return this.btnSalir; } |
| 136 | + public JButton getBtBuscar() { return this.btBuscar; } |
| 137 | + public JTextField getTfNRef() { return tfNRef; } |
| 138 | + public JTextField getTfEstado() { return tfEstado; } |
| 139 | + public JTable getTbInfo() { return tbInfo; } |
| 140 | + public JTable getTbMovimientos() { return tbMovimientos; } |
| 141 | +} |
0 commit comments