Pessoal, estou tentando pegar uma imagem, JPG, que tem um tamanho grande e coloca-lo em um JLabel, mas o mesmo não “ajusta” ao tamanho do JLabel, o que pode estar ocorrendo ? Segue um test-case.[code]package VeriFinger;
import java.awt.Container;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class Foto extends JFrame {
JLabel lFoto;
Container c;
Foto() {
inicia();
}
public void inicia() {
c = getContentPane();
c.setLayout(null);
this.setTitle("Foto");
this.setSize(400, 200);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
File f = new File("H://11854.jpg");
try {
BufferedImage image = ImageIO.read(f);
if (image == null) {
System.err.println("Invalido formato lido");
}
Icon iconFoto = new ImageIcon(image);
lFoto = new JLabel(iconFoto);
lFoto.setSize(80,130);
} catch (IOException e) {
e.printStackTrace();
}
c.add(lFoto);
repaint();
setVisible(true);
}
public static void main(String[] args) {
new Foto();
}
}[/code]