import java.awt.*; 
 import java.awt.event.*; 
 import javax.swing.*;
 import java.sql.*;
 import java.util.*;
 import java.net.*;
 import java.io.*;
 import javax.swing.border.*;

 public class userdetails extends JFrame 
 { 
 	private JLabel jLabel1; 
 	private JLabel jLabel2; 
 	private JLabel jLabel3; 
 	private JLabel jLabel4,jLabel5; 
 	 	private JLabel jLabel7; 
		private JLabel jLabel8;

	private JTextField jTextField1; 
	private JComboBox jComboBox1; 
 	private JComboBox jComboBox2; 
    private JTextField jTextField5; 
 	private JTextField jTextField7; 

 	private JButton jButton1; 
 	private JButton jButton2; 
	private JButton jButton3; 
	private JButton jButton4,jButton5; 
 	private JPanel contentPane; 
	private JPanel panel;
	public Runtime r;
	int n;
	int i=0,j2;
	String cost="",cost1="";
	int portno,n1;
	String nodename = "",node,des;
	String sysname = "";
	ResultSet rs;
	Connection cs;
	Statement st;
		Font font = new Font("TimesRoman",Font.PLAIN,20);
public Vector  totalpeer = new Vector();
  
  public Vector v = new Vector();

 	public userdetails() 
 	{ 
 		super(); 
		
	
 		initializeComponent(); 
 		
 		this.setVisible(true); 
 	} 
  
 	 
 	public void initializeComponent() 
 	{ 
 		jLabel1 = new JLabel(); 
 		jLabel2 = new JLabel(); 
 		jLabel3 = new JLabel(); 
 		jLabel4 = new JLabel(); 
		jLabel5 = new JLabel(); 
				jLabel7= new JLabel(); 

		panel=new JPanel();
 		jTextField1 = new JTextField(); 
 		
		jTextField5 = new JTextField(); 
			jTextField7 = new JTextField(); 
 	    jButton1 = new JButton(); 
 		jButton2 = new JButton(); 
			jButton3 = new JButton(); 
				jButton4 = new JButton(); 
				jButton5 = new JButton(); 
				jComboBox1 = new JComboBox(totalpeer); 
 		jComboBox2 = new JComboBox(totalpeer); 
 		contentPane = (JPanel)this.getContentPane(); 
       
 		jLabel8.setIcon(new ImageIcon("home.jpg"));
 	
 		jLabel2.setText("Node"); 
 		
 		
		jLabel3.setText("Source"); 

 		
 		jLabel4.setText("Neighbour"); 
		jLabel5.setText("Node limits"); 
 		
		
 		jButton1.setText("Submit"); 
 		jButton1.addActionListener(new ActionListener() { 
 			public void actionPerformed(ActionEvent e) 
 			{
				
				if(i<=n)
				
		{
		jButton1_actionPerformed(e); 
			if(i==n-1)
			{
				connect();
				
  
												jTextField7.setEnabled(true);

				jComboBox1.setEnabled(true);
				jComboBox2.setEnabled(true);
				jButton1.setEnabled(false);
				jTextField1.setEnabled(false);
			}
 				
				i++;
		}
			
		
 			} 
 		}); 
 		
 		jButton2.setText("Reset"); 
		//jButton2.setBackground(Colour.red);
 		jButton2.addActionListener(new ActionListener() { 
 			public void actionPerformed(ActionEvent e) 
 			{ 
				jTextField1.setText("");
			    jComboBox1.setSelectedItem("Select");
				jComboBox2.setSelectedItem("Select");
 				
 			} 
  
 		}); 
		jButton4.setText("Enter"); 
 		jButton4.addActionListener(new ActionListener() { 
 			public void actionPerformed(ActionEvent e) 
 			{ 
				try
				{
					String nodecount=jTextField5.getText();
				n=Integer.parseInt(nodecount);
				System.out.println("n:"+n);
				if(n!=0)
				{
					
				
				
				jTextField1.setEnabled(true);
				
				jButton1.setEnabled(true);

						jTextField5.setEnabled(false);
										jButton4.setEnabled(false);



				}
				}
				catch (Exception e1)
					{
					JOptionPane.showMessageDialog(null,"Please Enter Value");
				}
				
				
			
 				
 			} 
  
 		}); 
		jButton3.setText("Exit"); 
 		jButton3.addActionListener(new ActionListener() { 
 			public void actionPerformed(ActionEvent e) 
 			{ 
				dispose(); 				
 			} 
  
 		}); 

jButton5.setText("Connection"); 
 		jButton5.addActionListener(new ActionListener() { 
 			public void actionPerformed(ActionEvent e) 
 			{ 
						jButton5_actionPerformed(e); 
 			} 
  
 		}); 
 		// 
 		// contentPane 
 		// 

			
		jTextField1.setEnabled(false);
				jTextField7.setEnabled(false);

				jComboBox1.setEnabled(false);
				jComboBox2.setEnabled(false);
				jButton1.setEnabled(false);
				
 		contentPane.setLayout(null); 
		 		panel.setLayout(null);
         			panel.setBackground(Color.orange);
         			panel.setbackground(new ImageIcon("3.jpg"));
				
				
				
 	
 	
 		addComponent(contentPane,panel, 0,0,595,375); 
		addComponent(panel, jLabel2, 190,50,100,25); 
 		addComponent(panel, jLabel3, 330,50,100,25); 
 		addComponent(panel, jLabel4, 470,50,100,25); 
		addComponent(panel, jTextField1, 190,80,100,25); 
 		addComponent(panel, jComboBox1, 330,80,100,25); 
 		addComponent(panel,jComboBox2, 470,80,100,25); 
		addComponent(panel, jButton1, 240,170,100,25); 
 		addComponent(panel, jButton2, 160,270,100,25); 
		addComponent(panel, jButton3, 330,270,100,25); 
		addComponent(panel, jButton5, 400,170,100,25); 
        addComponent(panel, jLabel5, 50,50,100,25); 
 	    addComponent(panel,jTextField5, 50,80,100,25); 
 		addComponent(panel, jButton4, 80,170,100,25);
		addComponent(panel, jLabel8, 20,100,100,200); 
		Border etched=BorderFactory.createEtchedBorder();
		Border border=BorderFactory.createTitledBorder(etched,"User Details",TitledBorder.LEFT,TitledBorder.DEFAULT_JUSTIFICATION,font,Color.blue);
		panel.setBorder(border);
 		this.setTitle("Network Construction"); 
 		this.setLocation(new Point(300, 300));
 		this.setSize(new Dimension(600, 375)); 
 		this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); 
 		this.setResizable(false); 
 	} 
  
 	private void addComponent(Container container,Component c,int x,int y,int width,int height) 
 	{ 
 		c.setBounds(x,y,width,height); 
 		container.add(c); 
 	} 
  
 	
 	
 	
  
 	private void jButton1_actionPerformed(ActionEvent e) 
 	{ 

	
			nodename = jTextField1.getText();
			
				
			if(nodename.equals("")  )
		{
				            	JOptionPane.showMessageDialog(this,"Enter Proper Value");

		}
		
		else
		{
			try
		{

			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
			cs=DriverManager.getConnection("jdbc:odbc:server","sa","");
			st=cs.createStatement();
			rs= st.executeQuery("select * from NodeInformation where NodeName LIKE '"+nodename+"' ");  //OR SystemName LIKE '"+sysname+"'
            if(rs.next())
            {
            	JOptionPane.showMessageDialog(this,"The given Data already Exists");
				i--;
            }
            else
            	{	String query = "insert into NodeInformation values('"+nodename+"','0','192.168.1.4','ON')";
            		st.execute(query);	
            		JOptionPane.showMessageDialog(this,"Registration  Sucess fully Completed");
					jTextField1.setText("");

            	  }
		}
			
			catch(Exception ee)
				{
				JOptionPane.showMessageDialog(this,"Specify the Correct Value");
				System.out.println("Connectivity Error");
				ee.printStackTrace();
				i--;
				}
		}
				
			} 
  
 	private void jButton5_actionPerformed(ActionEvent e) 
 	{ 
		try
		{
			
		
		node = (String)jComboBox1.getSelectedItem();
		 des = (String)jComboBox2.getSelectedItem();
			System.out.println(""+node);
			System.out.println(""+des);
		
			if(node.equals("Select")||des.equals("Select"))
		{
			JOptionPane.showMessageDialog(this,"Specify the Nodes");
			}
			else if (node.equals(des))
			{
				JOptionPane.showMessageDialog(this,"Specify a Valid Neighbour");
			}
			
			else
		{
		

			try
		{

			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
			cs=DriverManager.getConnection("jdbc:odbc:server","sa","");
			st=cs.createStatement();
			rs= st.executeQuery("select * from Connection where NodeName LIKE '"+node+"' AND Neighbour LIKE '"+des+"'");  //OR SystemName LIKE '"+sysname+"'
            System.out.println("1");
			if(rs.next())
            {
            	JOptionPane.showMessageDialog(this,"The given Data already Exists");
           }
            else
            	{
				

				String query = "insert into Connection values('"+node+"','"+des+"','1','0')";
				String query1= "insert into Connection values('"+des+"','"+node+"','1','0')";
				
            		st.executeUpdate(query);	
					
					st.executeUpdate(query1);

            		JOptionPane.showMessageDialog(this,"Connection Information Completed");
            	}
								   					jTextField7.setText("");

			}
			catch(SQLException ee)
				{
				JOptionPane.showMessageDialog(this,"Specify the Correct Value");
				System.out.println("Connectivity Error");
				ee.printStackTrace();
				}

  
 	} 
		}
		
		catch (Exception e3)
		{
			JOptionPane.showMessageDialog(this,"Exception");
			e3.printStackTrace();
			
		}

		}
  public Vector connect()
 {
     
     try
     {
		 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
		 cs=DriverManager.getConnection("jdbc:odbc:server","sa","");
		 st=cs.createStatement();
         ResultSet rs=st.executeQuery("select NodeName from NodeInformation");
  		 totalpeer.add("Select");
		
         while(rs.next())
    	 {
		    totalpeer.addElement(rs.getString(1).trim());
			System.out.println(""+totalpeer);
         }
	 }
     catch (Exception ex)
     {
	   ex.printStackTrace();
     }
     return totalpeer;
  }
 	
  

	 
	
  
   

  
  
 }

check the image icon...and also content panel declaration...

Creaate class that extends JPanel and override the paintComponent method to draw the image.

Edit: Of course, it would help to know exactly what the problem is that you're having with it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.