DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2

Thread: Graphics

  1. #1
    Join Date
    May 2004
    Posts
    1

    Graphics

    I'm pretty much a Java "newbie", and need some help with my GUI. I have a graphic ('logo.bmp' at 66x70pixels) and I want to use it as my logo for the GUI, how do I go about this?

    Please keep in mind I'm not using HTML to access the *.java file, I'm using JCreator.


    Thanks in advance,
    Adam.

  2. #2
    Join Date
    Feb 2004
    Posts
    5
    I used a classPicLoader in order to load a picture.

    Code:
    class PicLoader
    {
    	/**
    	* Retreives and loads an image
    	*
    	* @param file the picture filename
    	* @param component the component that will show the picture (needed for the mediatracker)
    	*/
    	public static Image get(String file, Component component)
    	{
    		Image pic = Toolkit.getDefaultToolkit().getImage(component.getClass().getResource("/" + file));
    
    		MediaTracker tracker = new MediaTracker(component);
    		tracker.addImage(pic, 0);
    		try{ tracker.waitForAll(); }
    		catch(InterruptedException ie){}
    
    		return pic;
    	}
    }
    And from your GUI class you call this clas and give the filename as a parameter

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links