• 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:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
Sheriffs:
  • Devaka Cooray
  • paul wheaton
  • Mark Herschberg
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
  • Jj Roberts
Bartenders:
  • Carey Brown
  • salvin francis
  • Piet Souris

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: 26378
81
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);
}
}
 
Don't count your weasels before they've popped. And now for a mulberry bush related tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic