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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
public class Vignette extends JPanel implements MouseListener
{
static private JPanel droit = null, gauche = null;
private int width, height;
private String image, nom;
private JPanel conteneur, PAN_Gauche, PAN_Droit, PAN_Nom;
private JLabel LAB_NomFichier;
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(); conteneur.addMouseListener(this);
add(conteneur); conteneur.setLayout(new BorderLayout(0, 0));
//Conteneur Image
ThreadAffichageImage affichageImage = new ThreadAffichageImage(conteneur, this.width, this.height, this.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
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
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);
}
@Override
public String getName()
{
return nom;
}
@Override
public void setName(String nom)
{
this.nom = nom;
}
public void setCouleurSelection(Color couleurSelection)
{
PAN_Droit.setBackground(couleurSelection);
PAN_Gauche.setBackground(couleurSelection);
}
public void deselectionPanel()
{
if(droit != null && gauche != null)
{
droit.setBackground(new Color(204, 223, 242));
gauche.setBackground(new Color(204, 223, 242));
}
}
public void mouseClicked(MouseEvent e)
{
deselectionPanel();
setCouleurSelection(Color.green);
droit = PAN_Droit;
gauche = PAN_Gauche;
}
public void mousePressed(MouseEvent e) {}
public void mouseReleased(MouseEvent e) {}
public void mouseEntered(MouseEvent e) {}
public void mouseExited(MouseEvent e) {}
} |
Partager