/**
   * 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) {
      synchronized (q) {
        if (!q.running) q.start();
      }
    }

    /* 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);

    // This code should be changed after the RFE 4719336 is resolved
    // to not make the applet a FocusCycleRoot, but set it's
    // FocusTraversalPolicy only.
    setFocusCycleRoot(true);
    setFocusTraversalPolicy(
        KeyboardFocusManager.getCurrentKeyboardFocusManager().getDefaultFocusTraversalPolicy());

    enableEvents(AWTEvent.KEY_EVENT_MASK);
  }
Exemple #2
0
  /**
   * 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);
  }