Background dans java
Résolu/Fermé
leen.net
Messages postés
212
Date d'inscription
lundi 31 janvier 2011
Statut
Membre
Dernière intervention
14 mai 2014
-
10 mars 2012 à 20:37
leen.net Messages postés 212 Date d'inscription lundi 31 janvier 2011 Statut Membre Dernière intervention 14 mai 2014 - 26 mars 2012 à 01:07
leen.net Messages postés 212 Date d'inscription lundi 31 janvier 2011 Statut Membre Dernière intervention 14 mai 2014 - 26 mars 2012 à 01:07
Bonjour,
comment je peux mettre un background dans java pour JPanel. non une couleur, mais plutôt une image
comment je peux mettre un background dans java pour JPanel. non une couleur, mais plutôt une image
A voir également:
- Java -jar in background
- Waptrick java football - Télécharger - Jeux vidéo
- Jeux java itel football - Télécharger - Jeux vidéo
- Aux in - Forum Audio
- Cvbs in 1 - Forum Autoradio
- Ouvrir fichier .jar ✓ - Forum Windows
3 réponses
KX
Messages postés
16755
Date d'inscription
samedi 31 mai 2008
Statut
Modérateur
Dernière intervention
12 février 2025
3 020
25 mars 2012 à 23:32
25 mars 2012 à 23:32
Un exemple :
class ImagePanel extends JPanel { private final BufferedImage img; public ImagePanel(String filename) throws IOException { img = ImageIO.read(new File(filename)); setPreferredSize(new Dimension(img.getWidth(),img.getHeight())); } @Override public void paint(Graphics g) { g.drawImage(img, 0, 0, null); }; } class ImageFrame extends JFrame { public ImageFrame(String filename) throws IOException { setDefaultCloseOperation(EXIT_ON_CLOSE); setSize(500,500); add(new ImagePanel(filename)); } } public class Test { public static void main(String...args) throws IOException { new ImageFrame("D:\\test.png").setVisible(true); } }