1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
int x1 = jLabel1.getWidth();
int y1 = jLabel1.getHeight();
JFileChooser chooser = new JFileChooser();//création dun nouveau filechosser
chooser.setApproveButtonText("Choose this file..."); //intitulé du bouton
chooser.showOpenDialog(null); //affiche la boite de dialogue
//permet d'importer tout type d'extension (jpg, jpeg bmp gif)
try {
imgglobal = ImageIO.read(new File(chooser.getSelectedFile().getAbsolutePath()));
} catch (IOException e) {
}
imagelabel = imgglobal.getScaledInstance(x1,y1,Image.SCALE_DEFAULT);
imageagrandie = new ImageIcon(imagelabel);
jLabel1.setIcon(imageagrandie); |