/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.baldaccini.app.frame;

import br.com.baldaccini.app.Log;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.Toolkit;

/**
 *
 * @author USER
 */
public class Notificacao extends javax.swing.JFrame {

    /**
     * Creates new form Notificacao
     * @param mensagem
     */
    public Notificacao(String mensagem) {
        initComponents();
        iniciar(mensagem);
    }

    private void iniciar(String mensagem) {
        lblMensagem.setText(mensagem);
        Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(getGraphicsConfiguration());
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        setLocation(screenSize.width - 220, screenSize.height - getHeight() - 20 - insets.bottom);
    }

    public void efeitoFim() {
        try {
            Thread.sleep(5000);
        } catch (InterruptedException ex) {
            Log.log(ex.getMessage());
        }
        for (float i = 0.9f; i > 0.0f; i = i - 0.01f) {
            try {
                this.setOpacity(i);//vai ficando mais transparente até desaparecer
                this.repaint();
                Thread.sleep(20);
            } catch (InterruptedException ex) {
                Log.log(ex.getMessage());
            }
        }
        this.dispose(); //fecha o frame
    }

    /**
     * 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.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lblMensagem = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setUndecorated(true);

        lblMensagem.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(lblMensagem, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 182, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(lblMensagem, javax.swing.GroupLayout.DEFAULT_SIZE, 139, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel lblMensagem;
    // End of variables declaration//GEN-END:variables
}
