Ver Mensaje Individual
  #2 (permalink)  
Antiguo 15/12/2007, 10:35
vdpazmino
 
Fecha de Ingreso: mayo-2007
Mensajes: 210
Antigüedad: 17 años
Puntos: 8
Re: Agregar una imagen a un JFrame

Ahi te va un ejemplo de como lo hice:

public class MainFrame extends JFrame{

private Image image;

public MainDesktopPane() {
super();
image = new ImageIcon(getClass().getResource("/images/logo.png")).getImage();
}

@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
int h = (int)image.getHeight(null)/2;
int w = (int)(image.getWidth(null)/2);
g.drawImage(image, (int)getWidth()/2 - w, (int)getHeight()/2 - h, null);
}
}