Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is the preferred way of adding images to an application

Status
Not open for further replies.

pigsie

Programmer
Dec 19, 2000
307
GB
Hi

I am currently building an application which requires a background
image. To acheive this I have used an ImageIcon. Is this the standard
way of adding images to an application or is there a problem with this
approach. What is the most efficient way to add images to
appliactions?

Also I need to be able to add other components - images, buttons and
labels ontop of this background is this possible with an imageIcon?

Thanks in advance
 
Image i=(Toolkit.getDefaultToolkit()).getImage("./pic/abc.gif");
MediaTracker mt=new MediaTracker(someComponent);
mt.addImage(i,0);
try{
mt.waitForAll();
}catch(Exception e)
{System.out.println("an error occured loading image");}
Graphics g=someComponent.getGraphics();
g.drawImage(i,0,0,someComponent);

HINT: If you are going to use this as an app background and there is going to be any updating of the image then use double buffering(updating to an offscreen image and redrawing to application from that) or images will flicker and performance will not be good.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top