01: package org.zilonis.tool.ui;
02:
03: import java.awt.Color;
04: import java.awt.Component;
05: import java.awt.Graphics;
06: import java.awt.Insets;
07: import javax.swing.BorderFactory;
08: import javax.swing.SwingUtilities;
09: import javax.swing.border.Border;
10: import javax.swing.border.CompoundBorder;
11:
12: import org.jdesktop.fuse.InjectedResource;
13: import org.jdesktop.fuse.ResourceInjector;
14:
15: public class FrameBorder implements Border {
16: private final Border border;
17: private final Border inactiveBorder;
18:
19: ////////////////////////////////////////////////////////////////////////////
20: // THEME SPECIFIC FIELDS
21: ////////////////////////////////////////////////////////////////////////////
22: @InjectedResource
23: private Color lightColor;
24: @InjectedResource
25: private Color mediumColor;
26: @InjectedResource
27: private Color shadowColor;
28: @InjectedResource
29: private Color inactiveLightColor;
30: @InjectedResource
31: private Color inactiveMediumColor;
32: @InjectedResource
33: private Color inactiveShadowColor;
34:
35: public FrameBorder() {
36: ResourceInjector.get().inject(this );
37:
38: Border shadow = BorderFactory.createLineBorder(shadowColor);
39: Border medium = BorderFactory.createLineBorder(mediumColor);
40: Border light = BorderFactory.createLineBorder(lightColor);
41: border = new CompoundBorder(light, new CompoundBorder(medium,
42: shadow));
43:
44: shadow = BorderFactory.createLineBorder(inactiveShadowColor);
45: medium = BorderFactory.createLineBorder(inactiveMediumColor);
46: light = BorderFactory.createLineBorder(inactiveLightColor);
47: inactiveBorder = new CompoundBorder(light, new CompoundBorder(
48: medium, shadow));
49: }
50:
51: public void paintBorder(Component c, Graphics g, int x, int y,
52: int width, int height) {
53: if (SwingUtilities.getWindowAncestor(c).isActive()) {
54: border.paintBorder(c, g, x, y, width, height);
55: } else {
56: inactiveBorder.paintBorder(c, g, x, y, width, height);
57: }
58: }
59:
60: public Insets getBorderInsets(Component c) {
61: return border.getBorderInsets(c);
62: }
63:
64: public boolean isBorderOpaque() {
65: return border.isBorderOpaque();
66: }
67: }
|