|
-
February 29th, 2000, 05:00 PM
#1
show a image.gif as background
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.....
-
March 1st, 2000, 04:42 AM
#2
Re: show a image.gif as background
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, 12:22 PM
#3
Re: show a image.gif as background
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, 01:30 PM
#4
Re: show a image.gif as background
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/[email protected]^[email protected]/0
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|