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 / April 2007

Tip: Looking for answers? Try searching our database.

Logo not showing

Thread view: 
RANG - 23 Apr 2007 08:35 GMT
Hi,

Am new to java.

In front page of my project, i'm trying to load an logo using the code
below. but it didnt show the img in applet. Pls. tell me whats wrong
in this

import java.awt.*;
import java.applet.*;
/*<applet CODE="image.class" width=500 height=200></applet>*/
public class image extends applet
{
public void init()
{
Image img;
img=getImage(getCodeBase(),"rabbit.gif");
}
public void paint(Graphics g)
{
g.drawImage(img,10,10,this);
}
}
Thanks
Andrew Thompson - 23 Apr 2007 08:51 GMT
....
>Am new to java.

Those who are new to Java, are best off avoiding GUI'd
applications, and *especially* applets.
A good groups for people learning Java is comp.lang.java.help

>...it didnt show the img in applet.
...
>public class image extends applet
>{

Please indent code using the usual conventions,
though it is best to replace 'tab' characters with
spaces before posting.

>public void init()
>{
>Image img;
>img=getImage(getCodeBase(),"rabbit.gif");

<http://java.sun.com/javase/6/docs//api/java/applet/Applet.html#getImage(java.net.URL
)>
"This method always returns immediately,
whether or not the image exists."

It might be..
1) the Image cannot be found, or ..
2) the Image has not loaded yet.  

A simple debugging technique for the first,
is to print the URL that is formed by adding
the codebase to the name, and then trying a
'direct fetch' on that URL in a browser.

For the second one, a MediaTraker can be used..
<http://java.sun.com/javase/6/docs//api/java/awt/MediaTracker.html>

HTH

Signature

Andrew Thompson
http://www.athompson.info/andrew/

RANG - 23 Apr 2007 09:30 GMT
> ...
>
[quoted text clipped - 41 lines]
>
> Message posted via JavaKB.comhttp://www.javakb.com/Uwe/Forums.aspx/java-general/200704/1

Thanks for alot of technique andrews
Andrew Thompson - 23 Apr 2007 10:14 GMT
...
>Thanks for alot of technique andrews

You're welcome, but we* are generally more interested in
hearing the results (e.g. "URL was correct, but MediaTracker
solved the problem"), and note that my name is Andrew,
rather than Andrews.

* This helps not just me, but anyone else on the
group to know if more help is required - it also helps
anybody that finds the thread later, to know what
worked, and what did not work.

Good luck with it, and please get back to us
with the progress.

Signature

Andrew Thompson
http://www.athompson.info/andrew/



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.