Bonjour,
J'ai des difficultés a mettre a jour une image dans un jframe.
je fait appel a ma class image suite a un click sur un bouton,
le problème c'est que l'image affiché est toujours celle affiché la 1ère fois, même si l'image est modifié ailleur, quand je rappel la classe elle affichera l'image initiale est non pas la dernière version de mon image.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 public class Image extends JFrame { private ImageIcon im; private JLabel label; private JPanel pane; private int height; private int with; private String nom; public Image(int h, int w,String nom){ height=h; with=w; pane = new JPanel(); im = new ImageIcon(nom+".png" ); label = new JLabel(""); label.setIcon(im); label.setBounds(0, 0, height, with); setSize(height,with); setVisible(true); getContentPane().add(pane, BorderLayout.CENTER); pane.add(label); setDefaultCloseOperation(DISPOSE_ON_CLOSE); } }
Partager