-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImagePanel.java
More file actions
30 lines (25 loc) · 781 Bytes
/
ImagePanel.java
File metadata and controls
30 lines (25 loc) · 781 Bytes
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
package Interface;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JPanel;
public class ImagePanel extends JPanel {
private BufferedImage image;
private int hauteur;
private int largeur;
public ImagePanel() {
try {
image = ImageIO.read(new File("yams-fond.jpg"));
} catch (IOException ex) {
// handle exception...
}
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(image, 0, 0, getWidth(),getHeight(), this); // see javadoc for more info on the parameters
}
}