A voir également:
- Fond d'écran de mon jeu
- Double ecran - Guide
- Capture d'écran samsung - Guide
- Ecran noir pc - Guide
- Ecran d'accueil iphone - Guide
- Retourner ecran windows - Guide
2 réponses
metaGamer60
Messages postés
6
Date d'inscription
jeudi 29 août 2019
Statut
Membre
Dernière intervention
29 août 2019
1
Modifié le 29 août 2019 à 16:38
Modifié le 29 août 2019 à 16:38
il y a plein de solution je vais en proposer 1
tu créer ds ton projet un dossier source que tu appel img tu met ton img dedans et met se code en le modifiant a ta convenance
package help;
import java.awt.Image;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class Main extends JFrame{
JLabel l1 = new JLabel("");
Image img = new ImageIcon(this.getClass().getResource("/test.png")).getImage();
public Main() {
super("test");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(500, 500);
setLayout(null);
l1.setIcon(new ImageIcon(img));
l1.setBounds(0, 0, l1.getPreferredSize().width, l1.getPreferredSize().height);
add(l1);
setVisible(true);
}
public static void main(String[] args) {
Main main = new Main();
}
}
tu créer ds ton projet un dossier source que tu appel img tu met ton img dedans et met se code en le modifiant a ta convenance
package help;
import java.awt.Image;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class Main extends JFrame{
JLabel l1 = new JLabel("");
Image img = new ImageIcon(this.getClass().getResource("/test.png")).getImage();
public Main() {
super("test");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(500, 500);
setLayout(null);
l1.setIcon(new ImageIcon(img));
l1.setBounds(0, 0, l1.getPreferredSize().width, l1.getPreferredSize().height);
add(l1);
setVisible(true);
}
public static void main(String[] args) {
Main main = new Main();
}
}