seeting background image or color in JFrame in swing

public class JavaApplication12 extends JFrame {
    public void go()
      {
           JFrame frame=new JFrame();
        JButton wel=new JButton("WELCOME TO NOTE-MAKING STORE");
         Container c = JFrame.getContentPane();
         c.setBackground(Color.red);
    
      
  
       try{
        frame.setContentPane(new JLabel(new ImageIcon(ImageIO.read(new File("E:\\ad5.jpg")))));
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
      
      
         frame.getContentPane().add(wel);
         frame.setSize(1500,1500);
         frame.setVisible(true);
      
       //  frame.setContentPane(new JLabel(new ImageIcon("D:\\ad4.png")));
        
   wel.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e)
        {
            new video();

        }
    });
      }
    public static void main(String[] args) {
       JavaApplication12 obj=new JavaApplication12();
       obj.go();
        }
  

    }

I am getting 2 errors,one is the background image is just attached to the centre so I am unable to see the button which was placed already in the centre

then secondly my background color is not set for the frame.

Replies

You are reading an archived discussion.

Related Posts

Can u guide me about me about mainframe Right now I am just new in the company and working on mainframe technology. Many people told me to change the technology...
So I was wondering why C and C++ continue to be very relevant in the modern world. I found the reason that not only C and C++ are "THE" languages...
Hello friends, I have a requirement to display the pdf file in swing JPanel and restrict the user to save this pdf. I am having pdf in byte[] format. Anyone...
All the CrazyEngineers members are being advised (and requested) to wash and iron their respective CrazyEngineers T-Shirts. We've been getting reports that several (almost all?) of the owners of the...
We've decided to offer the CrazyEngineers T-Shirt at the craziest, lowest price [Rs. 340, includes all taxes and shipping as well!]. Use the following discount coupon when you place your...