Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

BackgroundPanel.java

By: a guest on Mar 26th, 2013  |  syntax: Java  |  size: 0.53 KB  |  views: 31  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import java.awt.Graphics;
  2. import java.awt.image.BufferedImage;
  3.  
  4. import javax.swing.JPanel;
  5.  
  6.  
  7. public class BackgroundPanel extends JPanel{
  8.        
  9.         BufferedImage backgroundImage;
  10.         GUIFrame window = null;
  11.        
  12.         public BackgroundPanel(BufferedImage image, GUIFrame windowFrame){
  13.                 backgroundImage = image;
  14.                 window = windowFrame;
  15.         }
  16.        
  17.         @Override
  18.         public void paintComponent(Graphics g){
  19.                 super.paintComponents(g);
  20.                 this.setVisible(true);
  21.                
  22.                 g.drawImage(backgroundImage, 0, 0, window.getWidth(), window.getHeight(), null);
  23.         }
  24. }