error: The local variable g may not have been initialized.

Discussion in 'Java' started by firsttry, Apr 1, 2011.

  1. firsttry

    firsttry New Member

    Joined:
    Apr 1, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi,

    I try to do drawOval in the JFrame as below (I want it as simple as possible). However, it not works. Can you tell me what I am missing?

    import javax.swing.*;
    import java.awt.*;
    public class MyFrameClass {
    public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setSize(500,300);
    frame.setVisible(true);
    Graphics g;
    g.drawOval(100,100,400,200); //error: The local variable g may not have been initialized.
    }
    }
     
  2. virxen

    virxen Active Member

    Joined:
    Nov 24, 2009
    Messages:
    387
    Likes Received:
    90
    Trophy Points:
    28

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice