/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package gui;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.InputVerifier;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 *
 * @author Csubák Péter
 */
public class MobirentErrorPane extends JPanel {

    public MobirentErrorPane(String msg, final JFrame form) {
        //setOpaque(false);

        this.setBackground(new Color(0, 0, 27, 200));
        this.setLayout(new GridLayout(1,1));

        JLabel label = new JLabel();

        msg.replaceAll("\n", "<br>");
        label.setText("<html><boby><center><b>" + msg + "</b><br><br><br><i>(Katt bárhova a bezáráshoz)</i></center></body></html>");
        label.setHorizontalAlignment(JLabel.CENTER);
        label.setVerticalAlignment(JLabel.CENTER);
        label.setFont(new Font("Arial", 0, 12));
        label.setForeground(new Color(255,255,255));
        label.setIcon(new javax.swing.ImageIcon(getClass().getResource("/res/alert.png")));
        label.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        label.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

        this.add(label);

        addMouseListener(new MouseAdapter() {

            @Override
            public void mouseClicked(MouseEvent e) {
                form.getRootPane().getGlassPane().setVisible(false);
            }

        });

        setInputVerifier(new InputVerifier() {
            @Override
            public boolean verify(JComponent input) {
                return !isVisible();
            }
        });

        this.validate();
        this.repaint();
    }

    /*
    @Override
    protected void paintComponent(Graphics g) {
        Graphics2D g2 = (Graphics2D) g.create();
        // fill the component with another translucent color
        g2.setColor(new Color(0, 0, 27, 200));
        g2.fillRect(0, 0, getWidth(), getHeight());
        g2.dispose();
    }*/

}
