File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jPanel background image help!

 
Gabriel Pedraza
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, i have a simple applet with two jPanel components. I use the first one to display a background image for the whole applet, and is working quite nicely. Inside this jPanel i have some buttons, labels, jTable, etc. and all is working fine. The problem is that i have a secondary jPanel in which i also need to display an image (much smaller that the background of the applet) but i cannot manage to get it drawn in the screen. Here is the sample code i am using:

jPanel1 = new javax.swing.JPanel() {
protected void paintComponent(Graphics g) {
g.drawImage(background,0,0,this);

}
};

jPanel2 = new javax.swing.JPanel(){
protected void paintComponent(Graphics g) { g.drawImage(coverArt.getScaledInstance(100,100,Image.SCALE_DEFAULT),0,0,this);
}
};

The result is that im having the image of the first jPanel always drawn but i cannot see the image in the second jPanel at all. Any ideas?
Thanks!
 
Campbell Ritchie
Sheriff
Pie
Posts: 47313
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"gpedraza," when you logged on you appear to have missed the naming policy which requires first name-space-last name. We do actually insist on that, so please go to "my profile" and correct your displayed name to comply.

CR
[ May 28, 2008: Message edited by: Campbell Ritchie ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic