title: Need help in correcting the painting in my small Swing Code
body: <p>What I want to make the content Pane transparent and that blue strip of normal dark bluecolour.But in the process of making contentPane transparent ,I am also making that strip as dull-coloured (coz that black colour is being painted over it) accidentally.</p>
  
  <p><img src="https://i.stack.imgur.com/PBsAP.png" alt="enter image description here"></p>
  
  <p>How can I correct it?</p>
  
  <p>(Comment out the paint method and notice the change in strip.This is what I want as final result)</p>
  
  <p>Here is the code:</p>
  
  <pre><code>class Home extends JFrame
  {
      int width=GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().width;
      int height=GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().height;
      public Home()
      {
          super("WiND");
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          setUndecorated(true);
          setSize(width,height);
          setBackground(new Color(0,0,0,0));
          setUndecorated(true);
          setVisible(true);
          setLayout(new FlowLayout());
  
          JPanel p=new JPanel();
          p.setBackground(new Color(0x0D70E8));
          p.setPreferredSize(new Dimension(width,height/10));
          add(p);
      }
      public void paint(Graphics g)
      {
          super.paint(g);
          Graphics2D g2=(Graphics2D)g;
          LinearGradientPaint p=new LinearGradientPaint(0,0,0,height,new float[]{0f,1f},new Color[]{new Color(0.2498f,0.2498f,0.2498f,0.3f),new Color(0.1598f,0.1598f,0.1598f,0.8f)});
          g2.setPaint(p);
          g2.fillRect(0, 0, width,height);
      }
  }
  </code></pre>
  
  <p>(I did that the same thing a year back,but now after a year I forgot how I did that)</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I made the changes to the paint() method only according to @Sage.I get the following output
  Correct Blue Strip but now the grey translucent background has gone.
  <img src="https://i.stack.imgur.com/hUeCx.png" alt="enter image description here"></p>