The Artima Developer Community
Sponsored Link

Java Answers Forum
How to add a image as a background

1 reply on 1 page. Most recent reply: Jun 7, 2003 10:19 AM by Charles Bell

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Mark Li

Posts: 1
Nickname: open0102
Registered: Jun, 2003

How to add a image as a background Posted: Jun 4, 2003 7:20 PM
Reply to this message Reply
Advertisement
I am just starting to learn Java
I know how to set the background color, something like this
setBackground (Color, blue)

but which methods should I use if I want to add a image
as a backgound

thank you very mcuh

Mark


Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: How to add a image as a background Posted: Jun 7, 2003 10:19 AM
Reply to this message Reply
Each component has a paint(Graphics g)
method.

For the component you want to override, you override its paint method and inside that method you write the

g.drawImage(...);

the Graphics class has several drawIamge methods to choose from.

Look in the Java Tutorial where there are numerous well written and explained examples.

Flat View: This topic has 1 reply on 1 page
Topic: yahoo games Previous Topic   Next Topic Topic: java.net.SocketException

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use