Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / July 2006

Tip: Looking for answers? Try searching our database.

Image loading and showing problem

Thread view: 
sacha.vdk@gmail.com - 13 Jul 2006 03:00 GMT
Hi,

I'm trying to make a little java application for my website, but I have
to load images. The compiling of the code gives no errors, but when I
run it, it says "Applet not initialized". I know wich row the message
causes, but I don't know how to solve it.
Here's the code:

-------------------------------------------------------------------------------------------------------------
import java.awt.*;
import java.applet.*;
import java.awt.Image.*;

public class App extends Applet {
    DeskTop desktop;

    public void init() {
        desktop = new DeskTop( );
    }

    public void paint(Graphics g) {
        desktop.paint( g );
    }
}

class DeskTop extends App {
    private String desktopimagename;
    private Image desktopimage;

    public DeskTop( ) {
        desktopimagename = "bg_Tiger.jpg";
        desktopimage = super.getImage(super.getDocumentBase(), "img/" +
desktopimagename);
    }

    public void paint( Graphics g ) {
        g.drawImage( desktopimage, 0, 0, super.WIDTH, super.HEIGHT, this );
    }
}
-------------------------------------------------------------------------------------------------------------

The code wich causes the message is the 23rd row:

desktopimage = super.getImage(super.getDocumentBase(), "img/" +
desktopimagename);

Does anybody know something that can solve this?

Thanks in advance...
John W. Kennedy - 13 Jul 2006 03:29 GMT
> Hi,
>
[quoted text clipped - 3 lines]
> causes, but I don't know how to solve it.
> Here's the code:

Your code makes no sense, in at least half a dozen ways. You really need
to get a good Java textbook, because whatever you're using now is only
confusing you.

Signature

John W. Kennedy
"The blind rulers of Logres
Nourished the land on a fallacy of rational virtue."
  -- Charles Williams.  "Taliessin through Logres: Prelude"

Oliver Wong - 13 Jul 2006 18:12 GMT
> Hi,
>
[quoted text clipped - 43 lines]
>
> Does anybody know something that can solve this?

   Get rid of the subclass, as it's causing a lot of problems.

<code>
import java.awt.*;
import java.applet.*;
import java.awt.Image.*;

public class App extends Applet {
 private String desktopimagename;
 protected Image desktopimage;

 public void init() {
   desktopimagename = "bg_Tiger.jpg";
   desktopimage = getImage(getDocumentBase(), "img/" + desktopimagename);
 }

 public void paint(Graphics g) {
   g.drawImage(desktopimage, 0, 0, super.WIDTH, super.HEIGHT, this);
 }
}
</code>

   - Oliver


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.