KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > rero > gui > background > BackgroundDesktop


1 package rero.gui.background;
2
3 import javax.swing.*;
4 import java.awt.*;
5
6 import rero.config.*;
7
8 import rero.gui.background.*;
9 import java.io.*;
10
11 public class BackgroundDesktop extends JPanel implements ClientStateListener
12 {
13    protected BackgroundProperties bgProperties;
14 // protected JDesktopPane desktop;
15
protected JComponent desktop;
16
17    public BackgroundDesktop(JComponent pane)
18    {
19       desktop = pane;
20
21       if (bgProperties == null)
22       {
23          bgProperties = new BackgroundProperties("desktop", BackgroundUtil.BG_DEFAULT);
24       }
25
26       ClientState.getClientState().addClientStateListener("desktop", this);
27    }
28
29    public Dimension getSize()
30    {
31       return desktop.getSize();
32    }
33
34    public void propertyChanged(String JavaDoc property, String JavaDoc parms)
35    {
36       repaint();
37    }
38
39    public void paint(Graphics g)
40    {
41       int x, y, width, height;
42
43       x = g.getClipBounds().x;
44       y = g.getClipBounds().y;
45       width = g.getClipBounds().width;
46       height = g.getClipBounds().height;
47
48       switch (bgProperties.getType())
49       {
50          case BackgroundUtil.BG_DEFAULT:
51            break;
52          case BackgroundUtil.BG_SOLID:
53            g.setColor(bgProperties.getColor());
54            g.fillRect(x, y, width, height);
55            paintChildren(g);
56            break;
57          case BackgroundUtil.BG_IMAGE:
58            BackgroundUtil.drawBackground(this, g, bgProperties);
59            paintChildren(g);
60            break;
61       }
62    }
63 }
64
Popular Tags