Je souhaite copier l'image contenue dans un JPanel dans un autre JPanel. Cela ne fonctionne pas.
Impossible d'afficher la seconde image... Seulement un bloc de la bonne taille, mais gris...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 private JPanel m_background = new JPanel(); private JPanel m_drawings = new JPanel(); //get the picture BufferedImage image = new BufferedImage( m_drawings.getWidth(), m_drawings.getHeight(), BufferedImage.TYPE_INT_RGB); Graphics2D g = image.createGraphics(); m_drawings.paintAll( g); g.dispose(); //draw the picture Graphics g2 = m_background.getGraphics(); g2.drawImage( image, 50, 50, 100, 100, null); g2.dispose();
Une idée ?
Christian
Partager