Java - Redimensionner ImageIcon
Problème
J'ai une question à propos d'ImageIcon en Java:
Je crée automatiquement des images au format jpg, qui peuvent être de toute taille. Et je mettrais l'image créée par un JLabel (taille spécifique) en 400x400.
- Comment afficher l'image en taille réelle dans JLabel?
Solution
ImageIcon icon = new ImageIcon ("tonImage.jpg"); Image img = icon.getImage (); BufferedImage bi = new BufferedImage (img.getWidth (null), img.getHeight (null), BufferedImage.TYPE_INT_ARGB); Graphiques g = bi.createGraphics (); g.drawImage (img, 0, 0, WIDTH, HEIGHT, null); IconImage newIcon = new IconImage (bi);
Merci à Marc pour ce conseil.