38 lines
886 B
Java
38 lines
886 B
Java
|
|
package fr.iut_fbleau.Avalam;
|
|||
|
|
|
|||
|
|
import javax.swing.*;
|
|||
|
|
import java.awt.*;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* La classe <code>BackgroundLayer</code>
|
|||
|
|
*
|
|||
|
|
* Sous composant de BoardView affichant l’image de fond.
|
|||
|
|
*/
|
|||
|
|
public class BackgroundLayer extends JComponent {
|
|||
|
|
private Image img;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Construit une couche de fond.
|
|||
|
|
*
|
|||
|
|
* @param resourcePath chemin de l'image de fond
|
|||
|
|
*/
|
|||
|
|
public BackgroundLayer(String resourcePath) {
|
|||
|
|
img = Toolkit.getDefaultToolkit().getImage(
|
|||
|
|
getClass().getClassLoader().getResource(resourcePath)
|
|||
|
|
);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Dessine l'image de fond.
|
|||
|
|
*
|
|||
|
|
* @param g contexte graphique
|
|||
|
|
*/
|
|||
|
|
@Override
|
|||
|
|
protected void paintComponent(Graphics g) {
|
|||
|
|
super.paintComponent(g);
|
|||
|
|
if (img != null) {
|
|||
|
|
g.drawImage(img, 0, 0, getWidth(), getHeight(), this);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|