Graphics


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

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

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


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center