Olá Pessoal, gostaria de saber como inserir uma imagem em um jFrame usando NetBeans!
Desde já, muito Obrigado a Todos
Olá Pessoal, gostaria de saber como inserir uma imagem em um jFrame usando NetBeans!
Desde já, muito Obrigado a Todos
então
vc tem que usar o metodo paint do JFrame
ai ele pinta um objeto da classe Graphics no JFrame
e nesse objeto vc põe a tua imagem
eae cara vc pode inserir uma imagem atraves de um JLabel
vc na area de edição visual inclui um JLabel no local onde vc quer que seja exibida a imagem e na janela de propriedades com o JLabel que vc inseriu selecionado
em text vc apada
e na propriedade icon vc define a imagem que o JLabel vai exibir
para definir tem um botão … no canto clica nele que vai abrir uma janela de auxilio pra vc definir a imagem e sua respectiva localização
eu montei um aki bem simples o codigo ficou assim:
public class testeForm extends javax.swing.JFrame {
/** Creates new form testeForm */
public testeForm() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
}
});
jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/teste/burnout.gif")));
getContentPane().add(jLabel1, java.awt.BorderLayout.CENTER);
pack();
}
/** Exit the Application */
private void exitForm(java.awt.event.WindowEvent evt) {
System.exit(0);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
new testeForm().show();
}
// Variables declaration - do not modify
private javax.swing.JLabel jLabel1;
// End of variables declaration
}

[]'s
Erko Bridee