title: How to add image in jframe in java swing?
body: <p>How to add image . i want to add image only above line not on whole jframe how can i do this in jframe swing. i tried but i ma able to set background image on whole screen.i need to set an background only above line.</p>
  
  <pre><code>import java.awt.*;
  import java.awt.event.*;
  import java.awt.geom.Line2D;
  import javax.swing.*;
  import java.sql.*;
  public class Demo1 extends JFrame
  {
  
    public void paint(Graphics g) {
          super.paint(g);  // fixes the immediate problem.
          Graphics2D g2 = (Graphics2D) g;
          Line2D lin = new Line2D.Float(20, 150, 1350, 150);
          g2.draw(lin);
      }       
  
    public Demo1(  )
    {
        {
        getContentPane().setBackground(new java.awt.Color(240,255,255));
        }     
        this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        Container c = getContentPane();
        c.setLayout( new FlowLayout() );
        setUndecorated(true);
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        setBounds(0,0,screenSize.width, screenSize.height); 
   }
  
    public static void main( String[] args )
    {
        Demo1 frame = new Demo1();
        frame.setVisible(true);
    }
  }
  </code></pre>