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
    22,324
    Thanks
    56
    Thanked 2,374 Times in 2,345 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,372
    Thanks
    183
    Thanked 836 Times in 779 Posts
    Blog Entries
    5

    Default Re: Why doesn't this work?

    mailman, I highly recommend reading the following:
    The problems with cross-posting
    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, 09: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, 10: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, 02: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, 11:24 AM