title: Painting pixels images in Java
body: <p>Which method is the best way to create a pixel image with java.
  Say, I want to create a pixel image with the dimensions 200x200 which are 40.000 pixels in total. How can I create a pixel from a random color and render it at a given position on a JFrame. </p>
  
  <p>I tried to create a own component which just creates pixel but it seems that this is not very performant if I create such a pixel a 250.000 times with a for-loop and add each instance to a JPanels layout.</p>
  
  <pre><code>class Pixel extends JComponent {
      @Override
      protected void paintComponent(Graphics g) {
          super.paintComponent(g);
          g.setColor(getRandomColor());
          g.fillRect(0, 0, 1, 1);
      }
  }
  </code></pre>