-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTampilCitra.java
49 lines (44 loc) · 1.46 KB
/
TampilCitra.java
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Odz
*/
public class TampilCitra { //extends JPanel
private javax.swing.ImageIcon citra;
public TampilCitra(java.io.File pathCitra) {
boolean gif = pathCitra.toString().endsWith(".gif");
// System.out.println(gif);
try {
if(!gif)
this.citra = new javax.swing.ImageIcon(javax.imageio.ImageIO.read(pathCitra));
else {
this.citra = new javax.swing.ImageIcon(pathCitra.toString()) ;
}
} catch (IOException ex) {
Logger.getLogger(TampilCitra.class.getName()).log(Level.SEVERE, null, ex);
}
}
public TampilCitra(java.awt.image.BufferedImage citra) {
this.citra = new javax.swing.ImageIcon(citra);
}
public javax.swing.ImageIcon getImage() {
return citra;
}
/*
private java.awt.Image citra;
public tampilCitra(java.io.File pathGambar) {
citra = new javax.swing.ImageIcon(pathGambar.getPath()).getImage();
}
@Override
public void paint(java.awt.Graphics g) {
super.paint(g);
g.drawImage(citra, 0, 0, this);
}*/
}