1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package ch.elca.el4j.services.gui.swing.frames;
18
19 import javax.swing.JComponent;
20 import javax.swing.JFrame;
21
22 import org.bushe.swing.event.annotation.AnnotationProcessor;
23
24 import ch.elca.el4j.services.gui.swing.wrapper.AbstractWrapperFactory;
25
26
27
28
29
30
31
32
33 public class ExternalApplicationFrame implements ApplicationFrame {
34
35
36
37
38 private JFrame m_frame;
39
40
41
42
43 public ExternalApplicationFrame(JFrame frame) {
44 m_frame = frame;
45 }
46
47
48 public JComponent getContent() {
49 return (JComponent) m_frame.getContentPane().getComponent(0);
50 }
51
52
53 public Object getFrame() {
54 return m_frame;
55 }
56
57
58 public void setFrame(Object frame) {
59 m_frame = (JFrame) frame;
60 }
61
62
63 public void setName(String name) {
64 m_frame.setName(name);
65 }
66
67
68 public void setContent(JComponent component) {
69 m_frame.setContentPane(component);
70
71 if (component instanceof ApplicationFrameAware) {
72 ApplicationFrameAware awareComponent = (ApplicationFrameAware) component;
73 awareComponent.setApplicationFrame(this);
74 }
75
76 m_frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
77 m_frame.pack();
78 }
79
80
81 public void setMinimizable(boolean minimizable) {
82
83 }
84
85
86 public void setMaximizable(boolean maximizable) {
87
88 }
89
90
91 public void setClosable(boolean closable) {
92
93 }
94
95
96 public void setTitle(String title) {
97 m_frame.setTitle(title);
98 }
99
100
101 public void setMinimized(boolean minimized) {
102 if (minimized) {
103 m_frame.setExtendedState(m_frame.getExtendedState() | JFrame.ICONIFIED);
104 } else {
105 m_frame.setExtendedState(JFrame.NORMAL);
106 }
107 }
108
109
110 public void setMaximized(boolean maximized) {
111 if (maximized) {
112 m_frame.setExtendedState(m_frame.getExtendedState() | JFrame.MAXIMIZED_BOTH);
113 } else {
114 m_frame.setExtendedState(JFrame.NORMAL);
115 }
116 }
117
118
119 public void show() {
120
121 AnnotationProcessor.process(getContent());
122
123 m_frame.setVisible(true);
124 }
125
126
127 public void setSelected(boolean selected) {
128
129 }
130
131
132 public void close() {
133 if (getContent() != null) {
134
135 AnnotationProcessor.unsubscribe(getContent());
136 }
137 AbstractWrapperFactory.removeWrapper(getContent());
138 m_frame.dispose();
139 }
140 }