Skip to content
Permalink
1f1e62ce07
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
45 lines (32 sloc) 972 Bytes
package view;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.LayoutManager;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JPanel;
public class StartScreenPanel extends JPanel {
private static final long serialVersionUID = 1L;
BufferedImage background = null;
StartScreenPanel(LayoutManager lm) {
super(lm);
background = loadImage("background.jpg");
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
g2d.drawImage(background, 0, 0, null);
}
public BufferedImage loadImage(String fileName) {
BufferedImage image = null;
try {
image = ImageIO.read(new File("src/images/" + fileName));
} catch (IOException e) {
e.printStackTrace();
}
return image;
}
}