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 43 44 45
| import java.awt.*;
import javax.swing.*;
public class Fenetre extends JFrame {
private JButton jbtn1, jbtn2;
private JLabel JL1, background;
public Image1(){
super("TutoGraphics");
setSize(500, 500);
setLocation(500, 0);
setAlwaysOnTop(true);
setResizable(true);
setLayout(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
///////////////////////////////////////////////
// //////JLabel1
JL1 = new JLabel("JLabel1");
JL1.setBounds(200, 200, 150 , 20);
JL1.setForeground(Color.white); // <<< Couleur du texte de votre label
JL1.setBackground(Color.orange); // <<< Couleur de fond de votre label
JL1.setOpaque(true);
// //////JButton 1
jbtn1 = new JButton("JButton 1");
jbtn1.setBounds(10, 10, 90, 25);
// //////JButton 2
jbtn2 = new JButton("JButton 2");
jbtn2.setBounds(385, 10, 90, 25);
// //////JLabel background image
background = new JLabel();
background.setBounds(0, 0, 500, 500);//Emplacement et sa taille
background.setIcon(new ImageIcon("CHEMIN DE VOTRE IMAGE DE FOND"));
///////////////////////////////////////////////
getContentPane().setBackground(Color.blue);
getContentPane().add(JL1);
getContentPane().add(jbtn1);
getContentPane().add(jbtn2);
getContentPane().add(background);
///////////////////////////////////////////////
setVisible(true);
}
public static void main(String[] args) {
new Fenetre();
}
} |
Partager