Mega Code Archive

 
Categories / Java / Swing JFC
 

Adding an Icon to a JLabel Component

import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JLabel; public class Main {   public static void main(String[] argv) throws Exception {     Icon icon = new ImageIcon("icon.gif");     JLabel label = new JLabel("Text Label", icon, JLabel.CENTER);     // a label with only an icon     label = new JLabel(icon);   } }