/* 
* Copyright 2016 Agencia Estatal de Administración Tibutaria
*
* Licencia con arreglo a la EUPL, Versión 1.1 o –en cuanto
* sean aprobadas por la Comisión Europea– versiones
* posteriores de la EUPL (la «Licencia»);
* Solo podrá usarse esta obra si se respeta la Licencia.
* Puede obtenerse una copia de la Licencia en:
*  
* https://joinup.ec.europa.eu/software/page/eupl
*  
* Salvo cuando lo exija la legislación aplicable o se acuerde
* por escrito, el programa distribuido con arreglo a la
* Licencia se distribuye «TAL CUAL», SIN GARANTÍAS NI CONDICIONES
* DE NINGÚN TIPO, ni expresasni implícitas.
*
* Véase la Licencia en el idioma concreto que rige los permisos y 
* limitaciones que establece la Licencia.
*/ 

package gestor;

public final class FormTicketVisual extends javax.swing.JDialog {

    javax.swing.Timer timerAutomatico;
    private int segundosFuera = 2;

    public FormTicketVisual(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        setLocationRelativeTo(parent);
        setSize(320, 250);
        preparaAutomatico();
        timerAutomatico.start();
    }

    public void setSegundosFuera(int v) {
        timerAutomatico.stop();
        segundosFuera = v;
        preparaAutomatico();
        timerAutomatico.start();
    }

    public void setTextoEtiqueta(String texto) {
        this.lbTicket.setText(texto);
    }

    public void setTextoSala(String texto) {
        this.lbSala.setText(texto);
    }

    public void setNif(String txt) {
        this.lbNif.setText(txt);
    }

    void preparaAutomatico() {
        timerAutomatico = new javax.swing.Timer(segundosFuera * 1000, new java.awt.event.ActionListener() {

         @Override
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cerrar();
            }
        });
    }

    void cerrar() {
        timerAutomatico.stop();
        dispose();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        lbTicket = new javax.swing.JLabel();
        lbSala = new javax.swing.JLabel();
        lbNif = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setModal(true);
        setResizable(false);

        jPanel1.setBackground(new java.awt.Color(255, 255, 204));
        jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 5, 15));

        jLabel1.setFont(new java.awt.Font("Arial", 1, 18));
        jLabel1.setText("Emitido tique número");
        jPanel1.add(jLabel1);

        getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);

        jPanel2.setBackground(new java.awt.Color(255, 255, 204));
        jPanel2.setLayout(new java.awt.GridLayout(3, 1, 5, 5));

        lbTicket.setBackground(new java.awt.Color(255, 255, 204));
        lbTicket.setFont(new java.awt.Font("Arial", 1, 48)); // NOI18N
        lbTicket.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lbTicket.setText("M-MMM");
        lbTicket.setOpaque(true);
        jPanel2.add(lbTicket);

        lbSala.setBackground(new java.awt.Color(255, 255, 204));
        lbSala.setFont(new java.awt.Font("Arial", 1, 36)); // NOI18N
        lbSala.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lbSala.setText("sala");
        jPanel2.add(lbSala);

        lbNif.setFont(new java.awt.Font("Arial", 1, 24)); // NOI18N
        lbNif.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lbNif.setText("nif");
        jPanel2.add(lbNif);

        getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER);

        jPanel3.setBackground(new java.awt.Color(255, 255, 204));
        jPanel3.setPreferredSize(new java.awt.Dimension(80, 50));
        jPanel3.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 5, 15));

        jButton1.setFont(new java.awt.Font("Arial", 1, 14));
        jButton1.setText("OK");
        jButton1.setPreferredSize(new java.awt.Dimension(70, 25));
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        jPanel3.add(jButton1);

        getContentPane().add(jPanel3, java.awt.BorderLayout.SOUTH);

        pack();
    }// </editor-fold>//GEN-END:initComponents
   private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
       this.dispose();
   }//GEN-LAST:event_jButton1ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JLabel lbNif;
    private javax.swing.JLabel lbSala;
    private javax.swing.JLabel lbTicket;
    // End of variables declaration//GEN-END:variables
}
