Can I display an image in a JLabel using HTML tags?
Created May 4, 2012
Sandip Chitale Here is a sample -
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class ImageInJLabel { public static void main(String[] args) { JFrame f = new JFrame("ImageInJLabel Example"); f.getContentPane().setLayout(new BorderLayout()); JLabel l = new JLabel("", JLabel.CENTER); l.setText("<html><center>Hello from jGuru<br>" + "<img src="http://www.jguru.com/jguru/images/logos/logos-blu-gr.gif" + "width=94 height=109></center></html>"); f.getContentPane().add(l, BorderLayout.CENTER); f.pack(); f.setVisible(true); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);}}); } }