1:
37:
38:
39: package ;
40:
41: import ;
42: import ;
43: import ;
44: import ;
45: import ;
46: import ;
47: import ;
48: import ;
49:
50: import ;
51: import ;
52:
53:
58: public class JApplet extends Applet
59: implements RootPaneContainer, Accessible
60: {
61:
64: protected class AccessibleJApplet extends Applet.AccessibleApplet
65: {
66:
69: protected AccessibleJApplet()
70: {
71: super();
72:
73: }
74: }
75:
76:
79: protected AccessibleContext accessibleContext;
80:
81: private static final long serialVersionUID = 7269359214497372587L;
82:
83: protected JRootPane rootPane;
84:
85:
88: protected boolean rootPaneCheckingEnabled = false;
89:
90: public JApplet()
91: {
92: super.setLayout(new BorderLayout(1, 1));
93: getRootPane();
94: setRootPaneCheckingEnabled(true);
95: }
96:
97: public Dimension getPreferredSize()
98: {
99: return super.getPreferredSize();
100: }
101:
102: public void setLayout(LayoutManager manager)
103: {
104:
105:
106: if (isRootPaneCheckingEnabled())
107: getContentPane().setLayout(manager);
108: else
109: super.setLayout(manager);
110: }
111:
112: public void setLayeredPane(JLayeredPane layeredPane)
113: {
114: getRootPane().setLayeredPane(layeredPane);
115: }
116:
117: public JLayeredPane getLayeredPane()
118: {
119: return getRootPane().getLayeredPane();
120: }
121:
122: public JRootPane getRootPane()
123: {
124: if (rootPane == null)
125: setRootPane(createRootPane());
126: return rootPane;
127: }
128:
129: protected void setRootPane(JRootPane root)
130: {
131: if (rootPane != null)
132: remove(rootPane);
133:
134: rootPane = root;
135: add(rootPane, BorderLayout.CENTER);
136: }
137:
138: protected JRootPane createRootPane()
139: {
140: return new JRootPane();
141: }
142:
143: public Container getContentPane()
144: {
145: return getRootPane().getContentPane();
146: }
147:
148: public void setContentPane(Container contentPane)
149: {
150: getRootPane().setContentPane(contentPane);
151: }
152:
153: public Component getGlassPane()
154: {
155: return getRootPane().getGlassPane();
156: }
157:
158: public void setGlassPane(Component glassPane)
159: {
160: getRootPane().setGlassPane(glassPane);
161: }
162:
163: protected void addImpl(Component comp, Object constraints, int index)
164: {
165:
166:
167: if (isRootPaneCheckingEnabled())
168: getContentPane().add(comp, constraints, index);
169: else
170: super.addImpl(comp, constraints, index);
171: }
172:
173: public AccessibleContext getAccessibleContext()
174: {
175: if (accessibleContext == null)
176: accessibleContext = new AccessibleJApplet();
177: return accessibleContext;
178: }
179:
180: public JMenuBar getJMenuBar()
181: {
182: return getRootPane().getJMenuBar();
183: }
184:
185: public void setJMenuBar(JMenuBar menubar)
186: {
187: getRootPane().setJMenuBar(menubar);
188: }
189:
190: protected String paramString()
191: {
192: return super.paramString();
193: }
194:
195: protected void processKeyEvent(KeyEvent e)
196: {
197: super.processKeyEvent(e);
198: }
199:
200: public void remove(Component comp)
201: {
202:
203:
204: if (comp == rootPane)
205: super.remove(rootPane);
206: else
207: getContentPane().remove(comp);
208: }
209:
210: protected boolean isRootPaneCheckingEnabled()
211: {
212: return rootPaneCheckingEnabled;
213: }
214:
215: protected void setRootPaneCheckingEnabled(boolean enabled)
216: {
217: rootPaneCheckingEnabled = enabled;
218: }
219:
220: public void update(Graphics g)
221: {
222: paint(g);
223: }
224: }