• 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

No progress...help

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please could any one help me...i know there are previous posts on this topic but i cannot understand what is going on in any of them as im a total beginner...
I want to display an image as the background on a jpanel...
Could anyone give me an example of the easiest and simplest code for this..

tanx in advanz
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you put "display an image as the background on a jpanel" into your favourite search engine, you will easily get a few examples of how to do that.

But you say you have already seen such things (or is that what you said?) and you don't understand them. Fair enough, that's normal for beginners. So what you have to do is work at learning the background until you do understand them. Asking for the code isn't going to help, you have probably already seen the code.
 
shane ocon
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok thanks for replying your prob right...

i found the code as below...is this image coming from a url on the net???
i want it to come from a folder...
class BackgroundPanel extends JPanel
{
Image image;
public BackgroundPanel()
{
try
{
image = javax.imageio.ImageIO.read(new java.net.URL(getClass().getResource("Test.gif"), "Test.gif"));
}
catch(Exception e){/*handled in paintComponent()*/}
}
public void paintComponent(Graphics g)
{
super.paintComponent(g);
if(image != null) g.drawImage(image, 0,0,this.getWidth(),this.getHeight(),this);
}
}
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic