Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: Why doesn't this work?

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Why doesn't this work?

    So the purpose of this code is to simply open my jpg in an applet viewer. Im not sure why but when i run the code below, the applet pops up but it doesnt show anything (blank white screen). Any help?

    import java.awt.*;
    import java.applet.*;


    public class Set_up extends Applet
    {
    Image img;

    public void init()
    {
    img = getImage(getDocumentBase(), "greek-flag.jpg");
    }


    public void paint(Graphics g)
    {
    g.drawImage(img,0,0,this);
    }
    }


  2. #2
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: Why doesn't this work?

    One thought is that you should call super first.

    super.paint(g);
    as the first statement inside your paint method.

  3. #3
    Junior Member
    Join Date
    Jan 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Why doesn't this work?

    Quote Originally Posted by javapenguin View Post
    One thought is that you should call super first.

    super.paint(g);
    as the first statement inside your paint method.
    thanks for the reply. nope still just a blank.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Why doesn't this work?

    Cross posted at Why doesn't this work?

  5. #5
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: Why doesn't this work?

    Please post the entire code.

  6. #6
    Junior Member
    Join Date
    Jan 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Why doesn't this work?

    Quote Originally Posted by javapenguin View Post
    Please post the entire code.
    this is the entire code.

  7. #7
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Why doesn't this work?

    mailman, I highly recommend reading the following:
    http://www.javaprogrammingforums.com...s-posting.html
    and
    http://www.javaprogrammingforums.com...t-println.html

Similar Threads

  1. Do you work out?
    By thesolo in forum Totally Off Topic
    Replies: 4
    Last Post: October 24th, 2011, 08:03 AM
  2. Why does this not work?
    By Spidey1980 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: August 12th, 2011, 09:47 AM
  3. NullPointerException ... and does it work?
    By thebestpearl in forum What's Wrong With My Code?
    Replies: 3
    Last Post: April 18th, 2011, 01:32 PM
  4. home work ..
    By shane1987 in forum Collections and Generics
    Replies: 8
    Last Post: November 16th, 2010, 09:45 AM
  5. My lines won't work!!!
    By The Mewzytion in forum What's Wrong With My Code?
    Replies: 5
    Last Post: July 2nd, 2010, 10:24 AM