Clase fondoP;
package Prgs;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Insets;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.border.Border;
/**
*
* @author wily
*/
public class fondoP implements Border {
BufferedImage fondo;
public fondoP(){
try {
URL url = new URL(getClass().getResource("/Imagenes/fondos.jpg").toString());
fondo = ImageIO.read(url);
}catch (IOException ex){
Logger.getLogger(fondoP.class.getName()).log(Level.SEVERE,null, ex);
} }
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height){
g.drawImage(fondo,(x+(width - fondo.getWidth())/2),(y+(height - fondo.getHeight())/2),null);
}
public Insets getBorderInsets(Component c){
return new Insets (0,0,0,0);
}
public boolean isBorderOpaque(){
return true;
}
}
No hay comentarios:
Publicar un comentario