Hello all !
First at all, im french, so sorry if my english looks bad.
I have a little problem…
I wan tto make my “main” with play and quit buttons, but, my frame juste show the last one i said to show.
If i code first buttons and background after, it show only the backgound, and vice versa.
here’s my code:
import java.awt.*;
import javax.swing.*;
public class fenetre {
JFrame fenetre ;
JButton jbPlay;
JButton jbClose;
JLabel label;
//***********french noy=tes.. :D*************
public fenetre(String titre) { //création de la méthode constructeur
fenetre = new JFrame(titre); //création de la Jframe
Container contenu = fenetre.getContentPane(); //création du conteneur
// ***************************************************************************************
// French notes again :P
JPanel Button = new JPanel(); // ceci pour contenir les boutons Jouer et Quitter
JButton jbPlay = new JButton("", new ImageIcon("jouer.gif"));
JButton jbClose = new JButton("", new ImageIcon("exit.gif"));
Button.add(jbPlay); //ajout des boutons au panel
jbPlay.setFocusPainted(false);
jbPlay.setBorderPainted(false); // ces trois lignes enelvent la bordure du boutton
jbPlay.setContentAreaFilled(false);
Button.add(jbClose);
jbClose.setFocusPainted(false);
jbClose.setBorderPainted(false); // ces trois lignes sont les meme que la haut :)
jbClose.setContentAreaFilled(false);
contenu.setLayout(new BorderLayout());
JLabel label = new JLabel();
Image image = Toolkit.getDefaultToolkit().createImage("background.gif");// nouveau JLabel backgound
label.setIcon(new ImageIcon(image));
contenu.add(label,BorderLayout.CENTER);
contenu.add(Button,BorderLayout.CENTER);
// *****************************caractéristiques de la fenetre*********************************
fenetre.setSize(600,500);
fenetre.setVisible(true);
fenetre.pack();
fenetre.setResizable(false);
fenetre.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}}

