01: package net.xoetrope.builder.editor.components.swing;
02:
03: import java.awt.Color;
04: import java.awt.Graphics;
05: import java.awt.Rectangle;
06: import javax.swing.BorderFactory;
07: import javax.swing.JComboBox;
08: import javax.swing.JComponent;
09: import javax.swing.JPanel;
10: import java.awt.FlowLayout;
11: import java.awt.Component;
12: import java.awt.Dimension;
13: import net.xoetrope.builder.editor.XuiDefaults;
14: import net.xoetrope.xui.XAppender;
15: import java.util.Vector;
16:
17: /**
18: * A stand-in for the menu bar so that it can be edited
19: * <p> Copyright (c) Xoetrope Ltd., 2002-2003</p>
20: * <p> $Revision: 1.5 $</p>
21: */
22: public class XMenuBarProxy extends JPanel implements XAppender {
23: private Vector menus;
24:
25: public XMenuBarProxy() {
26: setBorder(BorderFactory.createLineBorder(Color.red));
27: setLayout(new FlowLayout());
28: setOpaque(true);
29: setFont(XuiDefaults.defaultFont);
30:
31: menus = new Vector();
32: }
33:
34: /**
35: * Do any final setup needed
36: */
37: public void setup() {
38: }
39:
40: /**
41: * Only allow addition of menus
42: * @param c
43: */
44: public Component add(Component c) {
45: if (c instanceof XMenuProxy)
46: return super .add(c);
47:
48: return null;
49: }
50:
51: public void paintComponent(Graphics g) {
52: Rectangle rect = getBounds();
53: g.setColor(getBackground());
54: g.fillRect(1, 1, rect.width - 2, rect.height - 2);
55:
56: g.setColor(getForeground());
57: g.drawString("M", 6, 16);
58: }
59:
60: /**
61: * Get the maximum size for this component. As the component is only a stand-in
62: * for a runtime component we limit its size to 20x20
63: * @return
64: */
65: public Dimension getMaximumSize() {
66: return new Dimension(64, 24);
67: }
68:
69: /**
70: * Appends the object o to this item
71: * @param o the appended item
72: * @param name the menut item name
73: */
74: public void append(Object o, String name) {
75: menus.addElement(o);
76: }
77:
78: /**
79: * Get a child object by name
80: * @param name
81: * @return the child
82: */
83: public Object getObject(String name) {
84: return null;
85: }
86: }
|