• Como Poner Una Imagen En Un JLabel En Java

    Este es un sencillo snippet para representar una imagen desde java y adosarlo a un JLabel.

    String path = "/images/myicon.png";
    URL url = this.getClass().getResource(path);
    ImageIcon icon = new ImageIcon(url);
    
    JLabel label = new JLabel("some text");
    label.setIcon(icon);
    

    Así de fácil.

    Tags: , ,

Leave a comment