jdk/src/share/classes/sun/applet/AppletPanel.java
changeset 16092 129d7d8a7399
parent 5506 202f599c92aa
child 21785 fc0bfa7d9d95
equal deleted inserted replaced
16091:4eb1062acb5b 16092:129d7d8a7399
    43 import java.security.*;
    43 import java.security.*;
    44 import java.util.*;
    44 import java.util.*;
    45 import java.util.Collections;
    45 import java.util.Collections;
    46 import java.util.Locale;
    46 import java.util.Locale;
    47 import java.util.WeakHashMap;
    47 import java.util.WeakHashMap;
       
    48 import sun.awt.AWTAccessor;
    48 import sun.awt.AppContext;
    49 import sun.awt.AppContext;
    49 import sun.awt.EmbeddedFrame;
    50 import sun.awt.EmbeddedFrame;
    50 import sun.awt.SunToolkit;
    51 import sun.awt.SunToolkit;
    51 import sun.misc.MessageUtils;
    52 import sun.misc.MessageUtils;
    52 import sun.misc.PerformanceLogger;
    53 import sun.misc.PerformanceLogger;
   446 
   447 
   447                       // Validate the applet in event dispatch thread
   448                       // Validate the applet in event dispatch thread
   448                       // to avoid deadlock.
   449                       // to avoid deadlock.
   449                       try {
   450                       try {
   450                           final AppletPanel p = this;
   451                           final AppletPanel p = this;
   451 
   452                           Runnable r = new Runnable() {
   452                           EventQueue.invokeAndWait(new Runnable() {
   453                               public void run() {
   453                                   public void run() {
   454                                   p.validate();
   454                                       p.validate();
   455                               }
   455                                   }
   456                           };
   456                               });
   457                           AWTAccessor.getEventQueueAccessor().invokeAndWait(applet, r);
   457                       }
   458                       }
   458                       catch(InterruptedException ie) {
   459                       catch(InterruptedException ie) {
   459                       }
   460                       }
   460                       catch(InvocationTargetException ite) {
   461                       catch(InvocationTargetException ite) {
   461                       }
   462                       }
   476                       // Validate and show the applet in event dispatch thread
   477                       // Validate and show the applet in event dispatch thread
   477                       // to avoid deadlock.
   478                       // to avoid deadlock.
   478                       try {
   479                       try {
   479                           final AppletPanel p = this;
   480                           final AppletPanel p = this;
   480                           final Applet a = applet;
   481                           final Applet a = applet;
   481 
   482                           Runnable r = new Runnable() {
   482                           EventQueue.invokeAndWait(new Runnable() {
   483                               public void run() {
   483                                   public void run() {
   484                                   p.validate();
   484                                       p.validate();
   485                                   a.setVisible(true);
   485                                       a.setVisible(true);
   486 
   486 
   487                                   // Fix for BugTraq ID 4041703.
   487                                       // Fix for BugTraq ID 4041703.
   488                                   // Set the default focus for an applet.
   488                                       // Set the default focus for an applet.
   489                                   if (hasInitialFocus()) {
   489                                       if (hasInitialFocus())
   490                                       setDefaultFocus();
   490                                         setDefaultFocus();
       
   491                                   }
   491                                   }
   492                               });
   492                               }
       
   493                           };
       
   494                           AWTAccessor.getEventQueueAccessor().invokeAndWait(applet, r);
   493                       }
   495                       }
   494                       catch(InterruptedException ie) {
   496                       catch(InterruptedException ie) {
   495                       }
   497                       }
   496                       catch(InvocationTargetException ite) {
   498                       catch(InvocationTargetException ite) {
   497                       }
   499                       }
   510 
   512 
   511                     // Hide the applet in event dispatch thread
   513                     // Hide the applet in event dispatch thread
   512                     // to avoid deadlock.
   514                     // to avoid deadlock.
   513                     try {
   515                     try {
   514                         final Applet a = applet;
   516                         final Applet a = applet;
   515 
   517                         Runnable r = new Runnable() {
   516                         EventQueue.invokeAndWait(new Runnable() {
   518                             public void run() {
   517                                 public void run()
   519                                 a.setVisible(false);
   518                                 {
   520                             }
   519                                     a.setVisible(false);
   521                         };
   520                                 }
   522                         AWTAccessor.getEventQueueAccessor().invokeAndWait(applet, r);
   521                             });
       
   522                     }
   523                     }
   523                     catch(InterruptedException ie) {
   524                     catch(InterruptedException ie) {
   524                     }
   525                     }
   525                     catch(InvocationTargetException ite) {
   526                     catch(InvocationTargetException ite) {
   526                     }
   527                     }
   568                         showAppletStatus("notdestroyed");
   569                         showAppletStatus("notdestroyed");
   569                         break;
   570                         break;
   570                     }
   571                     }
   571                     status = APPLET_DISPOSE;
   572                     status = APPLET_DISPOSE;
   572 
   573 
   573                     try
   574                     try {
   574                     {
       
   575                         final Applet a = applet;
   575                         final Applet a = applet;
   576 
   576                         Runnable r = new Runnable() {
   577                         EventQueue.invokeAndWait(new Runnable()
   577                             public void run() {
   578                         {
       
   579                             public void run()
       
   580                             {
       
   581                                 remove(a);
   578                                 remove(a);
   582                             }
   579                             }
   583                         });
   580                         };
       
   581                         AWTAccessor.getEventQueueAccessor().invokeAndWait(applet, r);
   584                     }
   582                     }
   585                     catch(InterruptedException ie)
   583                     catch(InterruptedException ie)
   586                     {
   584                     {
   587                     }
   585                     }
   588                     catch(InvocationTargetException ite)
   586                     catch(InvocationTargetException ite)