Solved

Wallpaper in applet & frame

Posted on 1997-03-26
3
215 Views
Last Modified: 2012-05-04
Every time when I set the wallpaper, all the component
will be shaded by the wallpaper.How can I set the wallpaper
as the background in applet or frame?
0
Comment
Question by:kcheung3
3 Comments
 

Expert Comment

by:heech
ID: 1219271
For each component separately..try doing a setBackGround
to whatever color you want instead of the wallpaper?

0
 

Author Comment

by:kcheung3
ID: 1219272
In fact, I want to set the background with an image instead of background color.
Anyway, thank for your kind responds.
0
 

Accepted Solution

by:
mjl earned 50 total points
ID: 1219273
Here is an applet I grabbed somewhere to do tiled background:
I haven't personally used it so I cant ensure that it works but
give it a shot.

import java.awt.*;
import java.applet.Applet;

public class ExtendedPanel extends Applet {
      Image backgroundImage = null;

      // applet init() - recieve and load background image
      public void init() {
            backgroundImage = getImage(getDocumentBase().getParameter("BGImage"));
      }

      // applet update() - dont clear, paint over it
      public void update( Graphics g) {
            paint(g);
      }

      // applet paint() - paint applet
      public void paint(Graphics g) {
            if(backgroundImage != null) {
                  int x_offset = 0, y_offset = 0;
                  while(y_offset<this.size().height) {
                        x_offset = 0;
                        while(x_offset<this.size().width) {
                              g.drawImage(backgroundImage, x_offset, y_offset, this);
                              x_offset=x_offset+backgroundImage.getWidth(null);
                        }
                        y_offset=y_offset+backgroundImage.getHeight(null);
                  }
            } else {
                  g.clearRect(0, 0, this.size().width, this.size().height);
            }
      }
}


Best of luck with this.

0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question