Background dans java
Résolu
leen.net
Messages postés
212
Date d'inscription
Statut
Membre
Dernière intervention
-
leen.net Messages postés 212 Date d'inscription Statut Membre Dernière intervention -
leen.net Messages postés 212 Date d'inscription Statut Membre Dernière intervention -
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
- Jeux java itel - Télécharger - Jeux vidéo
- Waptrick java football - Télécharger - Jeux vidéo
- Aux in - Forum Audio
- Jeux java itel 5360 - Forum Mobile
- Ouvrir fichier .jar ✓ - Forum Windows
3 réponses
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); } }