CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2000
    Location
    Canada
    Posts
    249

    getGraphics() returning null

    I am trying to load an image into an application and display it in my program. When I try to get the graphics in the example below, the graphics object is null. How can I get the graphics?

    Toolkit tk = getToolkit();
    bg = Color.blue;
    setBackground( bg );
    image1 = tk.getImage( "images/New.gif" );
    g.drawImage( image1, 3, 3, parent );


    -------------------------------------------
    T. Sean Ryan
    http://rastos0.kjm.htmlplanet.com

  2. #2
    Join Date
    Dec 1999
    Location
    Chonghe, Taipei County, Taiwan, R.O.C.
    Posts
    231

    Re: getGraphics() returning null

    You need use Component.getGraphics() to get the Graphics context for
    the component before you paint something on the component.
    good luck
    Alfred Wu


  3. #3
    Join Date
    Sep 1999
    Location
    Madurai , TamilNadu , INDIA
    Posts
    1,024

    Re: getGraphics() returning null


    you cant get the graphics inside a component's constructor. Check whether you have
    put this code inside the Component's constructor.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured