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
22 import org.xulux.api.gui.IPropertyHandler;
23 import org.xulux.api.gui.IWidget;
24 import org.xulux.api.gui.IWidgetInitializer;
25 import org.xulux.gui.Widget;
26
27
28
29
30
31
32
33 public class NativeWindow implements IWidgetInitializer {
34
35 protected JFrame frame;
36
37
38
39 public NativeWindow() {
40 super();
41
42 }
43
44
45
46
47 public void initialize(IWidget widget) {
48
49
50 frame = new JFrame();
51
52 ((Widget) widget).handleProperties(IPropertyHandler.INIT);
53
54 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
55 frame.setVisible(true);
56 }
57
58
59
60
61 public void destroy(IWidget widget) {
62 if (frame != null) {
63 frame.removeAll();
64
65
66 frame.setVisible(false);
67 Container container = frame.getParent();
68 if (container != null) {
69 container.remove(frame);
70 }
71 frame.dispose();
72 frame = null;
73 }
74 }
75
76 public Object getNativeWidget() {
77 return this.frame;
78 }
79
80 public boolean addToParent(IWidget widget) {
81 return false;
82 }
83
84 public void setNativeWidget(Object object) {
85 }
86
87 }