Results 1 to 3 of 3
  1. #1
    Skipito is offline Member
    Join Date
    Jul 2011
    Posts
    7
    Rep Power
    0

    Default Why does this code displays an error?

    Hello,

    I'm using a pretty old Java book to learn Java. It's from 2000 so I think it's a bit outdated... I hope not....

    Anyway, I installed the JDK and all that stuff, tested the compiler and the book says that I have to run the following code:

    Java Code:
    import java.awt.*;
    import java.applet.*;
    
    public class ToonJavaBoodschap extends Applet
    
      {
        public void paint (Graphic g)
          {
            g.drawString("Volle kracht vooruit met Java!", 5, 25);
          }
          
       }
    However, when I run this code, it displays an error:

    ''ToonJavaBoodschap.java:?: cannot find symbol
    symbol: class Graphic
    location: class ToonJavaBoodschap
    public void paint <graphics g>

    1 error''

    What am I doing wrong? Is it also possible that this example from this book is outdated and that something is different nowadays? Do you guys also recommend me to read this Java book which was written & published in 2000.

    Thanks!

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    I suggest head first java if you are new, I posted a blog on this forum with more book suggestions if you are interested.

    The paint method takes a Graphics object, not Graphic.

  3. #3
    0circle0 is offline Member
    Join Date
    Jul 2011
    Posts
    18
    Rep Power
    0

    Default

    as stated above
    Java Code:
    public void paint (Graphic[B]s[/B] g) //Graphics g, not Graphic g
          {
            g.drawString("Volle kracht vooruit met Java!", 5, 25);
          }

Similar Threads

  1. Need help making an applet that displays a pie chart.
    By jeskoston in forum New To Java
    Replies: 5
    Last Post: 05-14-2011, 01:33 AM
  2. button displays image
    By hopelessnoob in forum AWT / Swing
    Replies: 2
    Last Post: 03-12-2011, 04:44 PM
  3. Touch Displays
    By Ciwan in forum New To Java
    Replies: 4
    Last Post: 10-21-2010, 10:47 AM
  4. Error Eclipse &drjava displays wrong language
    By fenderman in forum New To Java
    Replies: 0
    Last Post: 02-28-2009, 04:24 AM
  5. Problem when displays in the terminal
    By Felissa in forum Advanced Java
    Replies: 2
    Last Post: 07-01-2007, 03:14 AM

Posting Permissions

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