Swing: Créer un label avec des images

Author:

 set, java, swing, awt, JFrame
{filelink=3356}


import javax.swing.*;
import java.awt.*;

public class LabelImage {

  private static Icon icon = new ImageIcon("c:/logo.gif");

  public static void main(String[] args)
  	{
  	// Créer un JLabel
    JLabel label= new JLabel();

    // Modifier l'icône de Label
    label.setIcon(icon);

    // Ajouter le Label à un JFrame
    JFrame frame = new JFrame( );
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container c = frame.getContentPane( );
    c.add(label);
    frame.setSize(350,150);

    // Afficher le JFrame
    frame.setVisible(true);
  }

}    

Leave a Reply

Your email address will not be published. Required fields are marked *