como posiciono a imagem?? tentei lbl.setBounds mas não deu…
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class Principal {
public JFrame frame;
public JLabel lbl;
public BufferedImage image;
String path = ("/im.jpg");
public void janela() {
frame = new JFrame();
frame.setSize(500, 500);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationRelativeTo(null);
image =new BufferedImage(100, 500,BufferedImage.TYPE_INT_RGB);
// ------------
try {
image =ImageIO.read(getClass().getResource(path));
} catch (IOException e) {
e.printStackTrace();
}
lbl = new JLabel();
lbl.setIcon(new ImageIcon(image.getScaledInstance(300, 400, 0)));
frame.add(lbl);
frame.setVisible(true);
}
public static void main(String[] args) {
Principal p1 = new Principal();
p1.janela();
}