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
|
//CODE ARRIERE PLAN PRINCIPAL (se trouvant dans la classe principale) :
/**
* ARRIERE PLAN
*/
class PanneauImageBgPrincipal extends JComponent {
boolean dimensionAutomatique = true;
static Image imageFond = new ImageIcon("background/bg (36).jpg").getImage();
@Override
public void paintComponent(Graphics fond) {
if (dimensionAutomatique)
fond.drawImage(imageFond, 0, 0, getWidth(), getHeight(), null);
else
fond.drawImage(imageFond, 0, 0, imageFond.getWidth(null), imageFond.getHeight(null), null);
}
}
// ET JE LAPPEL COMME CECI:
private PanneauImageBgPrincipal panneauImage = new PanneauImageBgPrincipal();
/
.
private void initControles() { //--CONSTRUCTEUR
/
.
panneauImage.setLayout(new BorderLayout());
add(panneauImage);
setVisible(true);
}
//CODE ARRIERE PLAN FENETRES (se trouvant dans la classe fenetre) :
/**
* ARRIERE PLAN
*/
@SuppressWarnings("serial")
class PanneauImageBgPanneaux extends JComponent {
boolean dimensionAutomatique = true;
public Image imageFond = new ImageIcon("background/bg (36)5.jpg").getImage();
public void paintComponent(Graphics fond) {
if (dimensionAutomatique)
fond.drawImage(imageFond, 0, 0, getWidth(), getHeight(), null);
else
fond.drawImage(imageFond, 0, 0, imageFond.getWidth(null), imageFond.getHeight(null), null);
}
}
// ENSUITE POUR CE QUI CONCERNE MA COMBOBOX :
private JComboBox<String> backgrounds;
/
.
private void initControles() { //--CONSTRUCTEUR
/
.
/**================== Changer arriere plan */
JLabel opt1 = new JLabel("Changer d'arrière plan");
opt1.setBounds(90, 40, 350, 30);
opt1.setForeground(Color.white);
opt1.setFont(ecritureOpt);
cadreOpt.add(opt1);
//---Ajouter une combobox
String [] choix = {"Bleu Design", "Lumilux", "Nature", "Beauty", "Abstrait"};
backgrounds = new JComboBox<String> ();
for (int i = 0; i<choix.length; i++) {backgrounds.addItem(choix[i]);} //--- Boucle qui ajoute au combobox les item du tableau donné
backgrounds.setBounds(548, 35, 180, 35);
backgrounds.setBackground(null);
backgrounds.setFont(ecritureOpt);
backgrounds.setForeground(Color.black);
backgrounds.setOpaque(false);
backgrounds.addActionListener(this);
cadreOpt.add(backgrounds);
} |
Partager