Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.samurai.guicore;
- import java.awt.Image;
- import javax.swing.JLabel;
- import javax.swing.JPanel;
- import javax.swing.ImageIcon;
- import java.io.File;
- import javax.imageio.ImageIO;
- import java.awt.image.BufferedImage;
- import java.io.IOException;
- public class StartImagePanel implements PanelFactory {
- private BufferedImage imageBuf;
- public StartImagePanel(String imageFilename) throws IOException {
- imageBuf = ImageIO.read(new File(imageFilename));
- }
- @Override
- public JPanel getPanel() {
- JLabel label = new JLabel();
- Image image = new ImageIcon(imageBuf).getImage();
- Image scaledImage = image.getScaledInstance(452, 640, java.awt.Image.SCALE_SMOOTH);
- label.setIcon(new ImageIcon(scaledImage));
- JPanel panel = new JPanel();
- panel.add(label);
- return panel;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement