ImagePanel.java added to display images
This commit is contained in:
parent
85ed728124
commit
d228415e41
28
cicaprojekt/ImagePanel.java
Normal file
28
cicaprojekt/ImagePanel.java
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package cicaprojekt;
|
||||||
|
|
||||||
|
import java.awt.Graphics;
|
||||||
|
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;
|
||||||
|
|
||||||
|
public ImagePanel(String path) {
|
||||||
|
try {
|
||||||
|
image = ImageIO.read(new File(path));
|
||||||
|
} catch (IOException ex) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void paintComponent(Graphics g) {
|
||||||
|
super.paintComponent(g);
|
||||||
|
g.drawImage(image, 0, 0, null); // see javadoc for more info on the parameters
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user