Setting Background image of JFrame containg Components

Step 1- Save the following source code in a file named "LoginPanel.java" import java.awt.*; import javax.swing.*; class BgPanel extends JPanel { Image bg = new ImageIcon("Back.jpg").getImage(); public void paintComponent(Graphics g) { g.drawImage(bg, 0, 0, getWidth(), getHeight(), this); } BgPanel() { JLabel l1=new JLabel("Username: "); JLabel l2=new JLabel("Password: "); JTextField t1=new JTextField(15); JTextField t2=new JTextField(15); JButton b1=new JButton("Login"); JButton b2=new JButton("Cancel"); l1.setBounds(20,40,90,25); l2.setBounds(20,70,90,25); t1.setBounds(120,40,170,25); t2.setBounds(120,70,170,25); ...