[b]Bonjour,
Pour ceux qui veulent ajouter une image comme arrière plan.
/b
package sans_titre2;
import java.awt.*;
import java.io.File;
import javax.swing.*;
import javax.swing.JFrame;
import javax.imageio.IIOException;
import javax.imageio.ImageIO;
import java.awt.event.ActionEvent;
public class Sans_titre1 extends JFrame{
JPanel contentPane;
JLabel jLabel1 = new JLabel();
private JMenuBar menubar ;
private JMenu fichier ;
private JMenu etat ;
private JMenu apropos;
public Sans_titre1(){
contentPane = (JPanel) this.getContentPane();
jLabel1.setFont(new java.awt.Font("Comic Sans MS", 1, 20));
jLabel1.setText("Salut, ca va ?");
jLabel1.setBounds(new Rectangle(0, 0,434, 332));
jLabel1.setIcon(new ImageIcon("./A.gif"));
contentPane.setLayout(null);
this.setSize(new Dimension(434, 332));
this.setTitle("Images arrier plan");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
menubar = new JMenuBar();
fichier = new JMenu("FICHIER");
etat = new JMenu("ETAT");
apropos=new JMenu("Apropos ");
menubar.add(fichier);
menubar.add(etat);
menubar.add(apropos);
setJMenuBar(menubar);
contentPane.add(jLabel1, null);
}
public static void main(String[] args) {
new Sans_titre1().show();
}
}
l'image
A.gif ce trouve dans la racine du repertoir.
la ligne
contentPane.add(jLabel1, null);, il faut toujour la garder en dernier.
bon courage
% Mauvais Sens %