Título: Problemas al insertar imagen desde un Thread Publicado por: Luis Daniel en 11 Mayo 2018, 21:58 pm import java.awt.Image;
import javax.swing.ImageIcon; import javax.swing.JLabel; public class taquilla implements Runnable { public taquilla() { // TODO Auto-generated constructor stub } public static void main(String[] args) { // TODO Auto-generated method stub } @Override public void run() { JLabel taquillero = new JLabel(""); Image img= new ImageIcon("Taquillero.png").getImage(); ImageIcon img2=new ImageIcon(img.getScaledInstance(200, 100, Image.SCALE_SMOOTH)); taquillero.setIcon(img2); taquillero.setBounds(100,10,30,30); taquillero.setSize(taquillero.getPreferredSize()); simulador.ventanasim.add(taquillero); } } Título: Re: Problemas al insertar imagen desde un Thread Publicado por: Damian616 en 15 Junio 2018, 04:38 am intenta esto:
ImageIcon Foto = new ImageIcon(getClass().getResource("src/taquillero.png")); Icon taquillero = new ImageIcon(Foto.getImage().getScaledInstance(LbFoto.getWidth(), LbFoto.getHeight(), Image.SCALE_DEFAULT));//**Ajustar imagen de foto a label LbFoto.setIcon(taquillero); ::) |