Solved

Wallpaper in applet & frame

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Weekend adv creator 3 51
how to see all occupied ports on windows 10 laptop 15 75
Need Help! Getting a syntax error and don't understand why 3 31
Setup GlassFish 4 21
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

809 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