Java - Redimensionar ImageIcon
Questão
Eu tenho uma pergunta sobre o ImageIcon em Java:
Eu meu aplicativo cria automaticamente imagens jpg, que podem ser de qualquer tamanho. E eu colocaria a imagem criada por um JLabel (tamanho específico) em 400x400.
- Como ter a imagem exibida em tamanho real no JLabel?
Solução
ImageIcon icon = new ImageIcon ("tonImage.jpg"); Imagem img = icon.getImage (); BufferedImage bi = new BufferedImage (img.getWidth (nulo), img.getHeight (nulo), BufferedImage.TYPE_INT_ARGB); Gráficos g = bi.createGraphics (); g.drawImage (img, 0, 0, WIDTH, HEIGHT, nulo); IconImage newIcon = new IconImage (bi);
Obrigado ao Marc por essa dica.