KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jftp > gui > framework > HDesktopBackground


1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  */

16 package net.sf.jftp.gui.framework;
17
18 import net.sf.jftp.*;
19 import net.sf.jftp.config.*;
20
21 import java.awt.*;
22 import java.awt.event.*;
23 import java.awt.image.*;
24
25 import javax.swing.*;
26
27
28 public class HDesktopBackground extends JPanel implements MouseListener,
29                                                           ImageObserver
30 {
31     public ActionListener who = null;
32     private Image img;
33     private String JavaDoc image = null;
34     private String JavaDoc cmd = "default";
35
36     public HDesktopBackground(String JavaDoc image, ActionListener who)
37     {
38         this.image = image;
39         this.who = who;
40
41         img = HImage.getImage(this, image);
42         addMouseListener(this);
43         setVisible(true);
44     }
45
46     public void paintComponent(Graphics g)
47     {
48         if(!Settings.getUseBackground())
49         {
50             return;
51         }
52
53         int x = img.getWidth(this);
54         int y = img.getHeight(this);
55         int w = 2000 / x;
56         int h = 2000 / y;
57
58         for(int i = 0; i < w; i++)
59         {
60             for(int j = 0; j < h; j++)
61             {
62                 g.drawImage(img, i * x, j * y, this);
63             }
64         }
65     }
66
67     public void update(Graphics g)
68     {
69         paintComponent(g);
70     }
71
72     public void mouseClicked(MouseEvent e)
73     {
74     }
75
76     public void mousePressed(MouseEvent e)
77     {
78     }
79
80     public void mouseReleased(MouseEvent e)
81     {
82     }
83
84     public void mouseEntered(MouseEvent e)
85     {
86     }
87
88     public void mouseExited(MouseEvent e)
89     {
90     }
91
92     public boolean imageUpdate(Image image, int infoflags, int x, int y,
93                                int width, int height)
94     {
95         //if(width > 0 && height >0) repaint();
96
return true;
97     }
98 }
99
Popular Tags