Solved

Wallpaper in applet & frame

Posted on 1997-03-26
3
213 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now