Configurer un setToolTipText
Bonjour,
Lorsque je passe ma souris sur une affiche de cinéma, j'affiche le titre, le genre et l'année du film que représente l'affiche. Pour cela, j'utilise setToolTipText associé à une iconeImage. Cela marche, mais je n'arrive pas à modifier le rendu de l'infobulle en mettant l'info sur 3 lignes ("\n" ne marche pas) ou en mettant en gras.
Le code de mon objet film :
Code:
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
|
public class film
{
private String titre;
private int annee;
private String genre;
private String lien;
private ImageIcon affiche;
public film (String titre,int annee,String genre,String lien,ImageIcon affiche)
{
this.titre = titre;
this.annee = annee;
this.genre = genre;
this.lien = lien;
this.affiche = affiche;
}
public film getfilm(){return this;}
public ImageIcon getaffiche(){return this.affiche;}
public String getinfo()
{
String mes = "Titre: " + this.titre + " - " + "Genre: " + this.genre + " - " + "Année: " + this.annee;
return mes;
}
} |
Le code de ma BDD :
Code:
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
|
public class videotheque
{
private ArrayList<film> films;
public videotheque ()
{
films = new ArrayList<film>();
}
public void init()
{
String path= "C:\\Users\\Gab et Pat\\Desktop\\Pat\\Java\\bibliovd\\src\\biblio\\affiches\\";
films.add(new film ("4 minutes",2013,"comedie","lien", new ImageIcon (path + "4 minutes.jpg")));
films.add(new film ("7 vies",2013,"comedie","lien", new ImageIcon (path + "7 vies.jpg")));
}
public film getFilm(int i)
{
return films.get(i);
}
} |
Le code du rendu :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
JPanel disposition = new JPanel(new GridLayout(4,3,1,1));
for (int i=0; i<12; i++)
{
imagePanel = new JLabel();
film monFilm = maVideo.getFilm(i);
imagePanel.setToolTipText(monFilm.getinfo());
imagePanel.setIcon(monFilm.getaffiche());
disposition.add(imagePanel);
} |
Je souhaite donc modifier le rendu de : imagePanel.setToolTipText(monFilm.getinfo());
Je vous remercie.