Alguém sabe como posso colocar uma imagem de background em um JFrame no netBeans ?
seuFrame.setBackgroundImage(new Image("./images/seupng.png"));
Você pode adicionar essa imagem em um JLabel e adicioná-lo ao JFrame:
JLabel background = new JLabel(new javax.swing.ImageIcon(getClass().getResource("img/suaImagem.png")));
ou tbm pode criar uma classe
[code]public class JSeuPainel extends JPanel
{
Image im = new ImageIcon ( getClass ( ).getResource ( "/fundo.png" ) ).getImage ( ); ---- sua imagem
public void paintComponent ( Graphics g )
{
super.paintComponent ( g );
int x = ( this.getWidth ( ) - im.getWidth ( null ) ) / 2;
int y = ( this.getHeight ( ) - im.getHeight ( null ) ) / 2;
g.drawImage ( im , x , y , this );
}
} [/code]
a parte de fazer com um Jlavel eu sabia… eu queria saber … sem usar label.