/** * Creates a swing applet instance. * * <p>This constructor sets the component's locale property to the value returned by <code> * JComponent.getDefaultLocale</code>. * * @exception HeadlessException if GraphicsEnvironment.isHeadless() returns true. * @see java.awt.GraphicsEnvironment#isHeadless * @see JComponent#getDefaultLocale */ public JApplet() throws HeadlessException { super(); // Check the timerQ and restart if necessary. TimerQueue q = TimerQueue.sharedInstance(); if (q != null) { q.startIfNeeded(); } /* Workaround for bug 4155072. The shared double buffer image * may hang on to a reference to this applet; unfortunately * Image.getGraphics() will continue to call JApplet.getForeground() * and getBackground() even after this applet has been destroyed. * So we ensure that these properties are non-null here. */ setForeground(Color.black); setBackground(Color.white); setLocale(JComponent.getDefaultLocale()); setLayout(new BorderLayout()); setRootPane(createRootPane()); setRootPaneCheckingEnabled(true); setFocusTraversalPolicyProvider(true); sun.awt.SunToolkit.checkAndSetPolicy(this); enableEvents(AWTEvent.KEY_EVENT_MASK); }