Java - formaat van ImageIcon

Kwestie

Ik heb een vraag over ImageIcon in Java:

Ik mijn applicatie maakt automatisch afbeeldingen jpg, die van elke grootte kunnen zijn. En ik zou de afbeelding gemaakt door een JLabel (specifieke grootte) in 400x400 plaatsen.

  • Hoe kan de afbeelding in JLabel op ware grootte worden weergegeven?

Oplossing

 ImageIcon icon = new ImageIcon ("tonImage.jpg"); Afbeelding img = icon.getImage (); BufferedImage bi = new BufferedImage (img.getWidth (null), img.getHeight (null), BufferedImage.TYPE_INT_ARGB); Grafische weergave g = bi.createGraphics (); g.drawImage (img, 0, 0, WIDTH, HEIGHT, null); IconImage newIcon = new IconImage (bi); 

Bedankt Marc voor deze tip.

Vorige Artikel Volgende Artikel

Top Tips