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 / GUI / February 2005

Tip: Looking for answers? Try searching our database.

Changing javaLogo icon into my pictures?

Thread view: 
Dado - 26 Feb 2005 16:33 GMT
I tried to cnage the icon image of my JFrame  on a next way:

Image myPicture;

myPicture = Toolkit.getDefaultToolkit().getImage("pictures/myLogo.jpg");

myFrame.setIconImage(myPicture);

but, unfortunatelly, I didn't succeed. Java logo is still in a left corner
of my frame.

Where I did wrong?
John McGrath - 27 Feb 2005 04:57 GMT
> I tried to cnage the icon image of my JFrame  on a next way:
>
[quoted text clipped - 6 lines]
> but, unfortunatelly, I didn't succeed. Java logo is still in a left
> corner of my frame.

That should work, assuming the image file actually exists and is in the
right place.  The Toolkit getImage() method will try to load an image from
a file, relative to the current working directory, so "myLogo.jpg" should
be in the "pictures" subdirectory of the directory from which you run your
program.

Unless you need to give the user the ability to customize the image, you
should probably include it with your code, typically in a JAR file with
your classes.  To load an image from there, you could use the following
code instead:

   URL url = MyClass.class.getResource( "myLogo.jpg" );
   myPicture = Toolkit.getDefaultToolkit.getImage( url );

In that case, the image file would be placed in the same location as the
"MyClass.class" file.

Signature

Regards,

John McGrath



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.