Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

help with jPanel background image in netbeans

843806Feb 12 2008 — edited Feb 13 2008
first of all, sorry if this is the wrong thread.

my problem is, i'm trying to put a backround image in a jPanel using netbeans. I got this code here in this forum:
    
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
public class NewJFrame extends javax.swing.JFrame {
    public NewJFrame() {
        initComponents();
            ImageIcon image = new ImageIcon("C:\\VideoKarera\\bg.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.setOpaque(false);
		setContentPane( panel );
    }
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                NewJFrame JFrame = new NewJFrame();
                JFrame.setVisible(true);
                JFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		JFrame.setSize(1091, 689);
            }
        });
    }
}
when I select run then run main project, the project runs correctly with the picture. but the problem is the jPanel I've created does not show in the "Inspector" and "Design" panels so I can't design the project and add other components using the palette panel of netbeans.
is there a way to remedy this? sorry I'm just still a newbie in java programming and I only know how to use netbeans.

Edited by: mihwak on Feb 12, 2008 8:13 PM

Edited by: mihwak on Feb 12, 2008 8:13 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 12 2008
Added on Feb 12 2008
4 comments
1,261 views