1 pièce(s) jointe(s)
Fond background sous JBuilder
Bonjour
J'aimerais ajouter un fond (une image ) sur mon interface Graphique JBUILDER
Comment faire
j'ai utiliser cela mais ca marche pas
Voici la Class qui appel MON GUI , Donc je veux faire un fond au GUI
Veuillez trouver le CODE et la capture d ecrans de mon GUI
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 43 44 45 46 47
|
public class Login {
boolean packFrame = false;
//Construct the application
public Login() {
LoginGUI frame = new LoginGUI();
//Validate frames that have preset sizes
//Pack frames that have useful preferred size info, e.g. from their layout
if (packFrame) {
frame.pack();
}
else {
frame.validate();
}
//Center the window
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = frame.getSize();
if (frameSize.height > screenSize.height) {
frameSize.height = screenSize.height;
}
if (frameSize.width > screenSize.width) {
frameSize.width = screenSize.width;
}
frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
frame.setVisible(true);
}
//Main method
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch(Exception e) {
e.printStackTrace();
}
new Login();
}
public void paintComponent(Graphics g) {
Toolkit kit = Toolkit.getDefaultToolkit();
Image icone = kit.getImage("C:/image/photo.bmp" );
g.drawImage(icone ,0, 0,400 ,400, null); }
} |
merci