Image de fond et JButton ou autre
Salut le monde.
Je ne comprends pas pourquoi les deux JButton ne s'affiche pas normalement sur notre image.
Pouvez vous me dire ce qu'il ne va pas s'il vous plait, d'avance merci.
Citation:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| import java.awt.*;
import javax.swing.*;
public class Fenetre extends JFrame {
private Image img;
private JButton BTN1, BTN2;
private JTextField JTF1;
private JPanel pano;
public Fenetre(){
super("TutoGraphics");
setSize(500, 500);
setLocation(150, 150);
setVisible(true);
setAlwaysOnTop(true);
setResizable(false);
setLayout(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
////////JButton 1
BTN1 = new JButton("JButton 1");
BTN1.setBounds(10, 10, 90, 25);
add(BTN1);
////////JButton 2
BTN2 = new JButton("JButton 2");
BTN2.setBounds(385, 10, 90, 25);
add(BTN2);
////////Image
img = Toolkit.getDefaultToolkit().createImage("CHEMIN DE VOTRE IMAGE DE FOND");
}
public void paint(Graphics g){
g.drawImage(img, 0, 0, 500, 500, null);
}
public static void main(String[] args) {
new Fenetre();
}
} |