1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
public class Vignette extends JPanel
{
private int width, height;
private String image, nom;
private JPanel conteneur, PAN_Gauche, PAN_Droit;
public Vignette(int width, int height, String image, String nom)
{
this.width = width; this.height = height;
this.image = image; this.nom = nom;
//Conteneur
conteneur = new JPanel();
add(conteneur); conteneur.setLayout(new BorderLayout(0, 0));
//Conteneur Image
ThreadAffichageImage affichageImage = new ThreadAffichageImage(conteneur, width, height, image);
affichageImage.execute();
//Conteneur Gauche
PAN_Gauche = new JPanel();
PAN_Gauche.setBackground(new Color(204, 223, 242));
PAN_Gauche.setPreferredSize(new Dimension(
(int) (this.width * 0.2),
(int) (this.height * 0.85)));
conteneur.add(PAN_Gauche, BorderLayout.WEST);
//Conteneur Droit
PAN_Droit = new JPanel();
PAN_Droit.setBackground(new Color(204, 223, 242));
PAN_Droit.setPreferredSize(new Dimension(
(int) (this.width * 0.2),
(int) (this.height * 0.85)));
conteneur.add(PAN_Droit, BorderLayout.EAST);
//Conteneur Nom Fichier
JPanel PAN_Nom = new JPanel();
PAN_Nom.setPreferredSize(new Dimension(
this.width,
(int) (this.height * 0.15)));
conteneur.add(PAN_Nom, BorderLayout.SOUTH); PAN_Nom.setLayout(new BorderLayout());
//Fichier
JLabel LAB_NomFichier = new JLabel(this.nom);
LAB_NomFichier.setPreferredSize(new Dimension(
PAN_Nom.getPreferredSize().width,
PAN_Nom.getPreferredSize().height));
LAB_NomFichier.setOpaque(true);
LAB_NomFichier.setFont(new Font("Serif", Font.BOLD, 17));
LAB_NomFichier.setBackground(new Color(0x3c3c3e));
LAB_NomFichier.setForeground(Color.white);
LAB_NomFichier.setHorizontalAlignment(SwingConstants.CENTER);
LAB_NomFichier.setVerticalAlignment(SwingConstants.CENTER);
PAN_Nom.add(LAB_NomFichier);
}
} |
Partager