Reputation: 2573
I am trying to create virtual desktop. I complete successfully.But i am not able to set background image for jdesktoppane. I want to set background image and After adding image also the desktop pane work normally.Is anyone know means just tell me Thanks
Upvotes: 1
Views: 2213
Reputation: 2446
You can extend JDeskTopPane class with another member as image and then in constructor set the background to that image.
public ExtendedJDesktopPane(Image image) {
super();
this.image = image;
}
protected void paintComponent(Graphics g) {
g.drawImage(scaledImage, 0, 0, this);
}
EDIT: This is similar to the link provided below by Riduidel.. i just got late writing it.
Upvotes: 1
Reputation: 22300
From this thread at coderanch, a possible solution is to paint in the paintComponent method of your subclass of the JDesktopPane (or in your renderer for this class, which could be better).
Upvotes: 1