• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Multiple Panels Background Image

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to draw a background image on multiple panels which have been added to a frame. The panels change images frequently. I am having problems using the paintComponent. Is there any other alternative to set a background image of a panel which can be changed as needed. Thanks in advance
 
Rancher
Posts: 5008
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
paintComponent() should do the job.
How are you using it?
What is the problem you are having?
 
S. Shree
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a frame, I added a panel (panelA) within it with gridlayout and I further added multiple panels within the panelA like :

[] [] [] []
[] [] [] []
[] [] [] []

The [] brackets above signify the multiple panels. I need to add different jpg images to these panels. Images switch position upon user click on the panel.

I tried to make a class ImagePanel and used it to create objects of that type but it still do not work out. The ImagePanel class code is as below:



I got success achieving the panel layout like grid style, but still having problems with loading images onto the panel. Thanks in advance for your help.
[ June 25, 2008: Message edited by: S. Shree ]
 
S. Shree
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Update : if i remove the overridden paintComponent function my panels appear, if I dont my panels (the panel grid) disappears
 
Norm Radder
Rancher
Posts: 5008
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure, would need a code example to test with. Your extension of JPanel looks like the right way.

Try adding super.paintComponent(g) in your overridden method.
 
S. Shree
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a million Norm, it worked perfectly nice
 
reply
    Bookmark Topic Watch Topic
  • New Topic