Esempio n. 1
0
 /**
  * Sets the rootPane property. This method is called by the constructor.
  *
  * @param root the rootPane object for this applet
  * @see #getRootPane
  * @beaninfo hidden: true description: the RootPane object for this applet.
  */
 protected void setRootPane(JRootPane root) {
   if (rootPane != null) {
     remove(rootPane);
   }
   rootPane = root;
   if (rootPane != null) {
     boolean checkingEnabled = isRootPaneCheckingEnabled();
     try {
       setRootPaneCheckingEnabled(false);
       add(rootPane, BorderLayout.CENTER);
     } finally {
       setRootPaneCheckingEnabled(checkingEnabled);
     }
   }
 }
Esempio n. 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) {
      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);
  }
Esempio n. 3
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);
  }