title: Blackberry: Dowloading images in custom field slows VerticalFieldManager
body: <p>Here is the paint method of my custom field:</p>
  
  <pre><code>   protected void paint(Graphics graphics) {
  
              new downloadImage();
              Bitmap img =  downloadImage.connectServerForImage(this.poster);
  
  
              graphics.drawBitmap(0, 0, 100, 150, img, LEFT, TOP);
       }
  </code></pre>
  
  <p>Here is the connectServerForImage method:</p>
  
  <pre><code>public static Bitmap connectServerForImage(String url) {
  
            HttpConnection httpConnection = null;
            DataOutputStream httpDataOutput = null;
            InputStream httpInput = null;
            int rc;
  
            Bitmap bitmp = null;
            try {
             httpConnection = (HttpConnection) Connector.open(url);
             rc = httpConnection.getResponseCode();
             if (rc != HttpConnection.HTTP_OK) {
              throw new IOException("HTTP response code: " + rc);
             }
             httpInput = httpConnection.openInputStream();
             InputStream inp = httpInput;
             byte[] b = IOUtilities.streamToBytes(inp);
             EncodedImage hai = EncodedImage.createEncodedImage(b, 0, b.length);
             return hai.getBitmap();
  
            } catch (Exception ex) {
             System.out.println("URL Bitmap Error........" + ex.getMessage());
            } finally {
             try {
              if (httpInput != null)
               httpInput.close();
              if (httpDataOutput != null)
               httpDataOutput.close();
              if (httpConnection != null)
               httpConnection.close();
             } catch (Exception e) {
              e.printStackTrace();
  
             }
            }
            return bitmp;
           }
  </code></pre>
  
  <p>I'm putting multiple instances of my custom field into a verticalfieldmanager, but the images slows the scrolling down. It seems as if every time I scroll it runs the paint method again even though the image has already been downloaded.</p>
  
  <p>I'm thinking I will need to download the images in another thread? Someone lead me in the right direction.</p>