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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
| import java.awt.Color;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class Fenetre extends JFrame{
//Variables
private String titre;
private int xSize;
private int ySize;
private int xPosition;
private int yPosition;
//Constructeur
public Fenetre(String titre, int xSize, int ySize, int xPosition, int yPosition) {
//Titre de la fenêtre
this.setTitle(titre);
//Taille de la fenêtre
this.setSize(xSize, ySize);
//Emplacement
this.setLocation(xPosition, yPosition);
//Fin de l'application lors de la fermeture de la fenêtre
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Rend visible la fenêtre
this.setVisible(true);
//Rend possible le redimensionnement de la fenêtre
this.setResizable(true);
//Instanciation d'un objet JPanel
JPanel panel = new JPanel();
//Définition de sa couleur de fond
panel.setBackground(Color.ORANGE);
//On prévient notre JFrame que notre JPanel sera son content pane
this.setContentPane(new Panneau());
//On le définit comme visible
this.setVisible(true);
//Insertion d'une image
JLabel labelImage = new JLabel();
//Chargement de l'image
labelImage.setIcon(new ImageIcon("C:/j0099165.jpg"));
//Ajout de l'image
panel.add(labelImage);
}
//Getters & Setters
public String getTitre() {
return titre;
}
public void setTitre(String titre) {
this.titre = titre;
}
public int getxSize() {
return xSize;
}
public void setxSize(int xSize) {
this.xSize = xSize;
}
public int getySize() {
return ySize;
}
public void setySize(int ySize) {
this.ySize = ySize;
}
public int getxPosition() {
return xPosition;
}
public void setxPosition(int xPosition) {
this.xPosition = xPosition;
}
public int getyPosition() {
return yPosition;
}
public void setyPosition(int yPosition) {
this.yPosition = yPosition;
}
} |
Partager