KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > fractal > swing > JPanelImpl


1 // skeleton class automatically generated
2

3 package org.objectweb.fractal.swing;
4
5 import org.objectweb.fractal.api.control.BindingController;
6
7 import java.util.HashMap JavaDoc;
8 import java.util.Map JavaDoc;
9 import java.awt.Component JavaDoc;
10
11 import javax.swing.JComponent JavaDoc;
12
13 public class JPanelImpl
14   extends javax.swing.JPanel JavaDoc
15   implements JPanelItf, JPanelAttributes, BindingController
16 {
17
18   // fields manually added
19
public final static String JavaDoc LEFT_COMPONENT_BINDING = "left-component";
20   public final static String JavaDoc TOP_COMPONENT_BINDING = "top-component";
21   public final static String JavaDoc RIGHT_COMPONENT_BINDING = "right-component";
22   public final static String JavaDoc BOTTOM_COMPONENT_BINDING = "bottom-component";
23   public final static String JavaDoc CENTER_COMPONENT_BINDING = "center-component";
24   public final static String JavaDoc COMPONENTS_BINDING = "components";
25   public final static String JavaDoc LAYOUT_BINDING = "layout";
26   private JComponent JavaDoc left, top, right, bottom, center;
27   private Map JavaDoc components = new HashMap JavaDoc();
28   private java.awt.LayoutManager JavaDoc layout;
29
30   public JPanelImpl (java.awt.LayoutManager JavaDoc arg0, boolean arg1) {
31     super(arg0,arg1);
32   }
33   public JPanelImpl (java.awt.LayoutManager JavaDoc arg0) {
34     super(arg0);
35   }
36   public JPanelImpl (boolean arg0) {
37     super(arg0);
38   }
39   public JPanelImpl () {
40     super();
41   }
42
43   public String JavaDoc[] listFc () {
44     int s = components.size();
45     String JavaDoc[] result = (String JavaDoc[])components.keySet().toArray(new String JavaDoc[s + 6]);
46     result[s] = LEFT_COMPONENT_BINDING;
47     result[s+1] = TOP_COMPONENT_BINDING;
48     result[s+2] = RIGHT_COMPONENT_BINDING;
49     result[s+3] = BOTTOM_COMPONENT_BINDING;
50     result[s+4] = CENTER_COMPONENT_BINDING;
51     result[s+5] = LAYOUT_BINDING;
52     return result;
53   }
54
55   public Object JavaDoc lookupFc (String JavaDoc clientItfName) {
56     // put your own code here
57
if (clientItfName.equals(LEFT_COMPONENT_BINDING)) {
58       return left;
59     } if (clientItfName.equals(TOP_COMPONENT_BINDING)) {
60       return top;
61     } if (clientItfName.equals(RIGHT_COMPONENT_BINDING)) {
62       return right;
63     } if (clientItfName.equals(BOTTOM_COMPONENT_BINDING)) {
64       return bottom;
65     } if (clientItfName.equals(CENTER_COMPONENT_BINDING)) {
66       return center;
67     } else if (clientItfName.startsWith(COMPONENTS_BINDING)) {
68       return components.get(clientItfName);
69     } else if (clientItfName.equals(LAYOUT_BINDING)) {
70       return layout;
71     }
72     return null;
73   }
74
75   public void bindFc (String JavaDoc clientItfName, Object JavaDoc serverItf) {
76     // put your own code here
77
if (clientItfName.equals(LEFT_COMPONENT_BINDING)) {
78       left = (JComponent JavaDoc)serverItf;
79       super.add(left, "West");
80       validate();
81       repaint();
82     } if (clientItfName.equals(TOP_COMPONENT_BINDING)) {
83       top = (JComponent JavaDoc)serverItf;
84       super.add(top, "North");
85       validate();
86       repaint();
87     } if (clientItfName.equals(RIGHT_COMPONENT_BINDING)) {
88       right = (JComponent JavaDoc)serverItf;
89       super.add(right, "East");
90       validate();
91       repaint();
92     } if (clientItfName.equals(BOTTOM_COMPONENT_BINDING)) {
93       bottom = (JComponent JavaDoc)serverItf;
94       super.add(bottom, "South");
95       validate();
96       repaint();
97     } if (clientItfName.equals(CENTER_COMPONENT_BINDING)) {
98       center = (JComponent JavaDoc)serverItf;
99       super.add(center, "Center");
100       validate();
101       repaint();
102     } else if (clientItfName.startsWith(COMPONENTS_BINDING)) {
103       components.put(clientItfName, serverItf);
104       super.add((java.awt.Component JavaDoc)serverItf);
105       validate();
106       repaint();
107     } else if (clientItfName.equals(LAYOUT_BINDING)) {
108       layout = (java.awt.LayoutManager JavaDoc)serverItf;
109       super.setLayout(layout);
110       validate();
111       repaint();
112     }
113   }
114
115   public void unbindFc (String JavaDoc clientItfName) {
116     // put your own code here
117
if (clientItfName.equals(LEFT_COMPONENT_BINDING)) {
118       super.remove(left);
119       validate();
120       repaint();
121       left = null;
122     } if (clientItfName.equals(TOP_COMPONENT_BINDING)) {
123       super.remove(top);
124       validate();
125       repaint();
126       top = null;
127     } if (clientItfName.equals(RIGHT_COMPONENT_BINDING)) {
128       super.remove(right);
129       validate();
130       repaint();
131       right = null;
132     } if (clientItfName.equals(BOTTOM_COMPONENT_BINDING)) {
133       super.remove(bottom);
134       validate();
135       repaint();
136       bottom = null;
137     } if (clientItfName.equals(CENTER_COMPONENT_BINDING)) {
138       super.remove(center);
139       validate();
140       repaint();
141       center = null;
142     } else if (clientItfName.startsWith(COMPONENTS_BINDING)) {
143       Component JavaDoc c = (Component JavaDoc)components.get(clientItfName);
144       super.remove(c);
145       validate();
146       repaint();
147     } else if (clientItfName.equals(LAYOUT_BINDING)) {
148       layout = null;
149     }
150   }
151
152 }
153
Popular Tags