package meerkat.voting.gui.managment;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import java.awt.image.BufferedImage;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.imageio.ImageIO;
import java.io.File;
import java.io.IOException;

public class Printer {



    public static void printBallot(String filename) throws IOException {
        final JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//        bi = ImageIO.read(ImageResourceDemo.class.getResource("../resource/avatar6.jpeg"));
        BufferedImage bi = ImageIO.read(new File(filename));
        frame.add(new JLabel(new ImageIcon(bi)));
        frame.pack();
        frame.setAlwaysOnTop(true);
        frame.setLocationRelativeTo(null);
        Dimension screenSize = new Dimension(Toolkit.getDefaultToolkit().getScreenSize());
        int wdwLeft = 500 + screenSize.width / 2;
        int wdwTop = screenSize.height / 2;
        frame.setLocation(wdwLeft, wdwTop);
        frame.setVisible(true);
    }
}