KickJava   Java API By Example, From Geeks To Geeks.

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


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 BackgroundToolBar extends JToolBar implements ClientStateListener
12 {
13    protected static BackgroundProperties bgProperties;
14
15    public BackgroundToolBar()
16    {
17       if (bgProperties == null)
18       {
19          bgProperties = new BackgroundProperties("statusbar", BackgroundUtil.BG_DEFAULT);
20       }
21
22       ClientState.getClientState().addClientStateListener("statusbar", this);
23    }
24
25    public boolean isOpaque()
26    {
27       return (bgProperties.getType() == BackgroundUtil.BG_DEFAULT);
28    }
29
30    public void propertyChanged(String JavaDoc property, String JavaDoc parms)
31    {
32       repaint();
33    }
34
35    public void paint(Graphics g)
36    {
37       int x, y, width, height;
38
39       x = g.getClipBounds().x;
40       y = g.getClipBounds().y;
41       width = g.getClipBounds().width;
42       height = g.getClipBounds().height;
43
44       switch (bgProperties.getType())
45       {
46          case BackgroundUtil.BG_DEFAULT:
47            super.paint(g);
48            paintBorder(g);
49            break;
50          case BackgroundUtil.BG_SOLID:
51            g.setColor(bgProperties.getColor());
52            g.fillRect(x, y, width, height);
53            paintChildren(g);
54            break;
55          case BackgroundUtil.BG_TRANSPARENT:
56            BackgroundUtil.drawTintedTransparency(this, g, bgProperties);
57            paintChildren(g);
58            break;
59          case BackgroundUtil.BG_IMAGE:
60            BackgroundUtil.drawBackground(this, g, bgProperties);
61            paintChildren(g);
62            break;
63       }
64    }
65 }
66
Popular Tags