title: generate Icon with svg content
body: <p>I want to generate an icon with an svg icon content. For example a yellow circle with a face (svg file) in it. At the moment I have this code. </p>
  
  <ol>
  <li><p>The circle is in the right position but the svg is drawn all over the JPanel and if i resize the frame the svg is added all the time. </p></li>
  <li><p>The svg is loaded with white background and in the wrong size. </p></li>
  </ol>
  
  <p>Is there a way to make the background of the svg transparent and transform the svg to the circle size? </p>
  
  <p>As information: The svg file has got a transparent background (seen in adobe illustrator) but in Java its loaded white...</p>
  
  <pre><code>import java.awt.*;
  import java.awt.geom.*;
  import javax.swing.*;
  import org.apache.batik.swing.JSVGCanvas;
  
  public class IconTest extends JPanel{
  
      public IconTest(){
  
      }
  
      @Override
      protected void paintComponent(Graphics g) {
          Graphics2D g2d = (Graphics2D)g;
          super.paintComponent(g2d);
          this.setBackground(new Color(255,255,255));
          g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  
          // create icon body
          Ellipse2D iconBody = new Ellipse2D.Double(0, 0, 100, 100);
          g2d.setPaint(Color.YELLOW);
          g2d.draw(iconBody);
          g2d.fill(iconBody);
  
          // icon content
          JSVGCanvas svg = new JSVGCanvas();
          svg.setURI("file:/C:/Users/Linda/Desktop/smile.svg");
          add(svg);
      }
  
      public static void main(String[] args) throws Exception{
  
          JFrame frame = new JFrame("IconTest");
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.setSize(600,600);
          frame.setVisible(true);
          IconTest i = new IconTest();
          frame.add(i);
  
  
      }
  }
  </code></pre>
  
  <p>edit:</p>
  
  <p>bevor transforming the window size</p>
  
  <p><a href="https://i.stack.imgur.com/niq1r.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/niq1r.jpg" alt="enter image description here"></a></p>
  
  <p>after transforming the window size. The SVG is added all the time with white background and it's size depends on how fast i transform the window...</p>
  
  <p><a href="https://i.stack.imgur.com/b5hCA.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/b5hCA.jpg" alt="enter image description here"></a></p>
  
  <p>Edit: You can download the svg file <a href="http://www.flaticon.com/free-icon/emoticon-square-smiling-face-with-closed-eyes_42734" rel="nofollow noreferrer">here</a></p>