Exemple #1
0
      public void appletStateChanged(AppletEvent evt) {
        AppletPanel src = (AppletPanel) evt.getSource();

        switch (evt.getID()) {
          case AppletPanel.APPLET_RESIZE:
            {
              if (src != null) {
                resize(preferredSize());
                validate();
              }
              break;
            }
          case AppletPanel.APPLET_LOADING_COMPLETED:
            {
              Applet a = src.getApplet(); // j86.sun.applet.AppletPanel

              // Fixed #4754451: Applet can have methods running on main
              // thread event queue.
              //
              // The cause of this bug is that the frame of the applet
              // is created in main thread group. Thus, when certain
              // AWT/Swing events are generated, the events will be
              // dispatched through the wrong event dispatch thread.
              //
              // To fix this, we rearrange the AppContext with the frame,
              // so the proper event queue will be looked up.
              //
              // Swing also maintains a Frame list for the AppContext,
              // so we will have to rearrange it as well.
              //
              if (a != null)
                AppletPanel.changeFrameAppContext(frame, SunToolkit.targetToAppContext(a));
              else AppletPanel.changeFrameAppContext(frame, AppContext.getAppContext());

              break;
            }
        }
      }