• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Jpanel Back ground  RSS feed

 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I want to put picture in JPnel as bckgound how can i do that is thatposible
help thanks
 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try overriding the paintComponent() method of JPanel. In that method paint the image by storing it as an ImageIcon...!!

Try doin somethin like this...

import java.awt.Graphics & java.awt.Color...

Your Function should look somewhat like this :

[ April 20, 2006: Message edited by: Parth Bhatt ]
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I prefer to use a border to draw the background image. That way you don't have to subclass:

Here is a demo:
 
Ranch Hand
Posts: 85
 
nabi bux
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks But I want which Component Which Component I Pass From these funtions JPanel or other
Thanks for help
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by nabi bux:
Thanks But I want which Component Which Component I Pass From these funtions JPanel or other
Thanks for help


??? Could you explain what you are trying to say here ???
Is this a question?
 
nabi bux
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankd I got my Problem
 
nabi bux
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i got error at image.i0;
im using jdk1.4,3
package not found
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Package javax.imageio is part of J2SE version 1.4:

http://java.sun.com/j2se/1.4.2/docs/api/javax/imageio/package-summary.html

Please post a minimal example program and the error it generates for you.
 
nabi bux
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for helping
i geting you theme of my program
i have Jframe in which i put three panel panel1,panel2,panel3
i have set bck color of panel1,2 and i want to set bck picture in panel3
and three buttons this how i will solve this thanks again
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!