Hi Expert,
I am a newbies in java and i am trying to creat an image as a background on a GUI i created, but i am not getting any image dispalying as bacground.
Here is my code:
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
public class NewClass1 extends javax.swing.JFrame {
public NewClass1() {
initComponents();
ImageIcon image = new ImageIcon("C:\\myimage.jpg");
JLabel background = new JLabel(image);
background.setBounds(0, 0, image.getIconWidth(), image.getIconHeight());
getLayeredPane().add(background, new Integer(Integer.MIN_VALUE));
JPanel panel = new JPanel();
panel.add(background);
//panel.add(getLayeredPane);
panel.setOpaque(false);
setContentPane( panel );
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
NewClass1 JFrame = new NewClass1();
JFrame.setVisible(true);
JFrame.setBounds(20, 20, 600, 400);
JFrame.setDefaultCloseOperation(NewClass1.EXIT_ON_CLOSE);
JFrame.setSize(200, 689);
}
});
}
private void initComponents() {
throw new UnsupportedOperationException("Not yet implemented");
}
}
Can some check to see why i am not getting an image. If possible modify my code to give me the correct one that can get the image.
Thanks
Edited by: m_l on Nov 14, 2008 7:29 AM
Edited by: m_l on Nov 14, 2008 7:30 AM