Logo.java
上传用户:shengda799
上传日期:2007-01-10
资源大小:68k
文件大小:3k
源码类别:

图片显示

开发平台:

Java

  1. // Logo.java
  2. //
  3. // This software is Copyright 1998 by Mark Watson.
  4. // This software may be freely used for any purpose
  5. // and may be modified for any purpose as long as
  6. // you agree to the following:
  7. //
  8. // 1. Any bug fixes or enhancements that you make must be emailed
  9. //    back to Mark Watson (markw@markwatson.com) for possible
  10. //    inclusion in the source code base that is available at
  11. //    the web site www.markwatson.com (credit will be given
  12. //    to contributers).
  13. //
  14. // 2. This copyright notice must be kept with the source code
  15. //    and duplicated if you distribute a modified verison of
  16. //    this software in binary form.
  17. //
  18. // 3. You will not re-distribute the source code. Rather, any
  19. //    improvements to this program will be returned to Mark
  20. //    Watson so that there is always one source base at
  21. //    the web site www.markwatson.com (you may freely
  22. //    distribute compiled derived versions of this program
  23. //    without any restrictions as long as this entire
  24. //    copyright notice is reproduced with the application
  25. //    (e.g., in the 'help' or 'about' dialog box).
  26. //
  27. // 4. This software may not be used for any illegal purpose.
  28. //
  29. // 5. You take all responsibility for the use of this software:
  30. //
  31. // THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  32. // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  33. // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  34. // ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  35. // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  36. // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  37. // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  38. // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  39. // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  40. // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  41. // SUCH DAMAGE.
  42. // FreeWare contributers:
  43. //
  44. //   Name                        Email (optional)
  45. //   ----                        ----------------
  46. //
  47. //
  48. import java.awt.*;
  49. import java.awt.image.*;
  50. class Logo extends Canvas {
  51.   private Image image;
  52.   public Logo(Container my_parent, int xsize, int ysize) {
  53.     image = null;
  54.     setSize(xsize, ysize); // little kluge: must set size
  55.     parent = my_parent;
  56.   }
  57.   private Container parent;
  58.   public void setImage(Image im, int width, int height) {
  59.     image = im;
  60.     setSize(width, height); // little kluge: must set size
  61.     repaint();
  62.   }
  63.   public void clear() { image = null; }
  64.   public void paint (Graphics g) {
  65.     if (image!=null) g.drawImage(image, 0, 0, this);
  66.   }
  67. }