package tech.nevets.jaml.gui.panels;

import tech.nevets.jaml.util.ImageUtils;

import javax.swing.*;

public class CustomProgressBarPanel extends JPanel {
    private int progress = 0;
    private int width;
    private int height;

    public CustomProgressBarPanel(int width, int height) {
        this.width = width;
        this.height = height;

        JLabel progressBar = new JLabel();
        progressBar.setSize(getWidth(), getHeight());
        ImageIcon image = new ImageIcon(getClass().getClassLoader().getResource("assets/progressbar.png"));
        image = ImageUtils.resizeIcon(image, width, height);
        progressBar.setIcon(image);
        add(progressBar);
    }

    public int getProgress() {
        return progress;
    }

    public void setProgress(int progress) {
        this.progress = progress;
        setSize(((progress * width) / 100), height);
        repaint();
    }
}
