Setting background of a frame in Java

View previous topic View next topic Go down

Setting background of a frame in Java

Post by BIT0208-Shuvo on Wed Feb 09, 2011 4:59 pm

How can I set an image as the background of a frame in Java?????
Please help somebody bounce
avatar
BIT0208-Shuvo
Global Moderator-RC

Course(s) :
  • BIT

Blood Group : B+
Posts : 87
Points : 124

View user profile

Back to top Go down

Re: Setting background of a frame in Java

Post by BIT0122-Amit on Thu Feb 10, 2011 1:18 am

Can you please show us how you tried this? Smile
Of course, it is possible that you decided to ask us before you tried. But it is also possible that you tried yourself, made some mistake, and then you decided to ask us here. If it is the later case, then finding out the problem will allow you to learn more Very Happy

_________________________________________________________________
Adminship / Moderatorship is not about power, it is about Responsibility.

|About me|My Blog|
avatar
BIT0122-Amit
Founder
Founder

Course(s) :
  • BIT

Blood Group : O+
Posts : 4187
Points : 6605

View user profile http://iitdu.forumsmotion.com

Back to top Go down

Re: Setting background of a frame in Java

Post by BIT0129-Tabassum on Thu Feb 10, 2011 1:18 am

This topic is going to move in Programming and brainstorming chamber. Programming related hleps should go there Smile

Topic has moved to this section Neutral

_________________________________________________________________
মানুষ তার স্বপ্নের সমান বড়
avatar
BIT0129-Tabassum
Global Moderator
Global Moderator

Course(s) :
  • BIT

Blood Group : A+
Posts : 1496
Points : 2298

View user profile http://probe-tabassum.blogspot.com

Back to top Go down

Re: Setting background of a frame in Java

Post by BIT0102-Mohaimin on Thu Feb 10, 2011 1:54 am

You can do it by overriding the paint() method.

Try this:

Code:

void paint(Graphics g){
  g.drawImage(img, 0, 0);
}

I assumed that img is the reference to the image you want to set as background.
the drawImage method has several forms. Find which is appropriate for you.

Note that, you must make all the components on the window transparent. Otherwise the image will not be visible.
avatar
BIT0102-Mohaimin
Programmer
Programmer

Course(s) :
  • BIT

Blood Group : B+
Posts : 415
Points : 715

View user profile

Back to top Go down

Re: Setting background of a frame in Java

Post by BIT0208-Shuvo on Thu Feb 10, 2011 3:31 am

BIT0122-Amit wrote:Can you please show us how you tried this? Smile
Of course, it is possible that you decided to ask us before you tried. But it is also possible that you tried yourself, made some mistake, and then you decided to ask us here. If it is the later case, then finding out the problem will allow you to learn more Very Happy
I've tried it several times in several ways. but I couldn't get my expected UI outlook. That's why I need help from someone.

Thanks to Mohaimin vai for helping. Now I'm trying this.
avatar
BIT0208-Shuvo
Global Moderator-RC

Course(s) :
  • BIT

Blood Group : B+
Posts : 87
Points : 124

View user profile

Back to top Go down

Re: Setting background of a frame in Java

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum