Have you covered object orientation yet?
At a guess what you have done before was using Applets? Applet[1] have a method called getGraphics(), and when you extended Applet, you inhereted its functionallity.
class MyClass extends Applet
Now you are not extending applet, so you need to create an object to draw on. Applets are for webpages, but as you are using
public static void main
I'm guessing you don't want an applet. Take a look at Frame[2]. And read the tutorials below.
Resources for Beginners
Sun's basic Java tutorial - http://java.sun.com/docs/books/tutorial/
Sun's New To Java Center.
http://java.sun.com/learning/new2java/index.html
Includes an overview of what Java is, instructions for setting up Java, an intro to programming (that includes links to the above tutorial or to parts of it), quizzes, a list of resources, and info on certification and courses.
javaalmanac.com
http://javaalmanac.com]
A couple dozen code examples that supplement
The Java Developers Almanac
http://www.amazon.com/exec/obidos/tg/detail/-/0201752808?v=glance
jGuru.
http://www.jguru.com
A general Java resource site. Includes FAQs, forums, courses, more.
JavaRanch.
http://www.javaranch.com
To quote the tagline on their homepage: "a friendly place for Java greenhorns." FAQs, forums (moderated, I believe), sample code, all kinds of goodies for newbies. From what I've heard, they live up to the "friendly" claim.
Bruce Eckel's Thinking in Java (Available online.)
http://mindview.net/Books/DownloadSites
Joshua Bloch's [url=http://www.amazon.co.uk/exec/obidos/Author=Bloch,%20Josh]Effective Java[/url]
Bert Bates and Kathy Sierra's [url=http://www.amazon.com/exec/obidos/tg/detail/-/0596004656?v=glance]Head First Java[/url]. This one has been getting a lot of very positive comments lately.
[1] http://java.sun.com/j2se/1.5.0/docs/api/java/applet/Applet.html
[2] http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Frame.html
> I don't see why I can't call getGraphics from
> http://java.sun.com/j2se/1.5.0/docs/api/index.html?jav
> a/awt/Frame.html
You have posted a link to the Frame class, and yes you can call that method on a Frame, but you neither have a frame nor extends frame.
/Kaj