Click to See Complete Forum and Search --> : show a image.gif as background
OOZON
February 29th, 2000, 04:00 PM
i'm programming a application in JAVA with JBuilder and i need to know if it's possible to display a image.gif as background instead of the usual Color
...and if it's possible ... wath is the source code to program such a thing.....
kib63613
March 1st, 2000, 03:42 AM
You may use Component.getGraphics() to get the Graphics object
and use Graphics.drawImage() to paint your image in the background.
Of course, you may load your image in advance.
good luck
Alfred Wu
March 1st, 2000, 11:22 AM
Hi,friends:
I am new java programmer. I have the same problem. How can i change the background of a button to an image when I press this button?
Cna anybody tell me where can i find the source code like this?
thank you very much!
March 1st, 2000, 12:30 PM
I had this problem months ago... and searched this database extensively...
Here is my response which works well..
JBackgroundPanel jbp;
.
jbp = new JBackgroundPanel(Toolkit.getDefaultToolkit().getImage("images/loginbg1.jpg"));
GridBagLayout gridbag = new GridBagLayout();
jbp.setLayout(gridbag);
jbp.add(User); //where these are JTextfields
jbp.add(Pass);
Win.getContentPane().add(jbp); //displayed in window but any container will work
.
.
.
class JBackgroundPanel extends JPanel { Image im;
JBackgroundPanel(Image im) { super(); this.im = im; }
public void paintComponent(Graphics g) { g.drawImage(im,0,0,this); } }
And for futher info check out this ...
http://forum.java.sun.com/forum?13@227.KZx4a1IVbdN^0@.ee7754d/0
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.