Java Memorandom- Graphics.drawImage

In paint(Graphics g) call back, use drawImage() to draw an image. It is crucial to specify ImageObserver parameter.

I mistakenly passed a null to the parameter, and the drawing was not done properly. It renders only when any other event forces to repaint. When the parameter was properly set, the rendering happens correctly so that the image shows up from the beginning.

public class MyPanel extends Panel
{
    public
void paint(Graphics g)
    {
        if(
null != image)
        {
           
g.drawImage(image, imageX, imageY, this);
        }
    }
}

Graphics.drawImage
Interface ImageObserver

新しいコメントの投稿

このフィールドの内容は非公開にされ、公表されることはありません。
  • ウェブページアドレスとメールアドレスは、自動的にハイパーリンクに変換されます。
  • 使用できるHTMLタグ: <a> <em> <strong> <code> <cite> <ul> <ol> <li> <dl> <dt> <dd> <p>
  • 行と段落は自動的に折り返されます。
  • Amazon製品へのリンクを次の形式で作成することが出来ます。[amazon product_id inline|full|thumbnail]. 例: [amazon 1590597559 thumbnail]
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • 画像を追加することが出来ます。

書式オプションに関するより詳しい情報...

認証コード
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
画像で表示されている数字および記号を入力してください。