1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.xulux.guilayer.swing.natives;
17
18 import java.awt.Container;
19
20 import javax.swing.JFrame;
21 import javax.swing.JMenuBar;
22
23 import org.xulux.api.gui.IWidget;
24 import org.xulux.api.gui.IWidgetInitializer;
25
26
27
28
29
30
31
32 public class NativeMenuBar implements IWidgetInitializer {
33
34 JMenuBar menuBar;
35
36
37
38
39 public NativeMenuBar() {
40 super();
41 }
42
43 public void initialize(IWidget widget) {
44 this.menuBar = new JMenuBar();
45 }
46
47 public void destroy(IWidget widget) {
48 menuBar.removeAll();
49 Container container = menuBar.getParent();
50 if (container != null) {
51 container.remove(menuBar);
52 }
53 menuBar = null;
54 }
55
56 public Object getNativeWidget() {
57 return this.menuBar;
58 }
59
60
61
62
63 public boolean addToParent(IWidget widget) {
64 Object nativeParent = widget.getParent().getNativeWidget();
65 if (nativeParent instanceof JFrame) {
66
67 ((JFrame) nativeParent).setJMenuBar(this.menuBar);
68 return true;
69 }
70 return false;
71 }
72
73 public void setNativeWidget(Object object) {
74 }
75
76 }