LaCaraDeLaVerga

Panel // background

Oct 10th, 2016
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.54 KB | None | 0 0
  1. package APP;
  2.  
  3. import java.awt.Dimension;
  4. import java.awt.Graphics;
  5.  
  6. import javax.swing.ImageIcon;
  7. import javax.swing.JPanel;
  8.  
  9. public class Panel extends JPanel {
  10.  
  11.     /**
  12.      * Create the panel.
  13.      */
  14.     ImageIcon imagen ;
  15.     String nombre ;
  16.     public Panel(String nombre) {
  17.         this.nombre=nombre;
  18.     }
  19. public void paint (Graphics g){
  20.     Dimension tamanio = getSize();
  21.     imagen = new ImageIcon(getClass().getResource(nombre));
  22.     g.drawImage(imagen.getImage(), 0, 0, tamanio.width , tamanio.height,null);
  23.     setOpaque(false);
  24.     super.paint(g);
  25. }
  26.  
  27.  
  28. }
Add Comment
Please, Sign In to add comment