21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package sun.applet;
27
28 import java.util.*;
29 import java.io.*;
30 import java.awt.*;
31 import java.awt.event.*;
32 import java.awt.print.*;
33 import javax.print.attribute.*;
34 import java.applet.*;
35 import java.net.URL;
36 import java.net.SocketPermission;
37 import java.security.AccessController;
38 import java.security.PrivilegedAction;
39 import sun.awt.SunToolkit;
40 import sun.awt.AppContext;
41 import sun.misc.ManagedLocalsThread;
42
43 /**
44 * A frame to show the applet tag in.
45 */
46 @SuppressWarnings("serial") // JDK-implementation class
47 final class TextFrame extends Frame {
48
49 /**
50 * Create the tag frame.
51 */
52 @SuppressWarnings("deprecation")
53 TextFrame(int x, int y, String title, String text) {
54 setTitle(title);
55 TextArea txt = new TextArea(20, 60);
56 txt.setText(text);
57 txt.setEditable(false);
58
59 add("Center", txt);
60
61 Panel p = new Panel();
837 p.sendEvent(AppletPanel.APPLET_STOP);
838 p.sendEvent(AppletPanel.APPLET_DESTROY);
839 p.sendEvent(AppletPanel.APPLET_DISPOSE);
840 p.sendEvent(AppletPanel.APPLET_QUIT);
841 }
842
843 /**
844 * Close this viewer.
845 * Stop, Destroy, Dispose and Quit an AppletView, then
846 * reclaim resources and exit the program if this is
847 * the last applet.
848 */
849 void appletClose() {
850
851 // The caller thread is event dispatch thread, so
852 // spawn a new thread to avoid blocking the event queue
853 // when calling appletShutdown.
854 //
855 final AppletPanel p = panel;
856
857 new ManagedLocalsThread(new Runnable()
858 {
859 @Override
860 public void run()
861 {
862 appletShutdown(p);
863 appletPanels.removeElement(p);
864 dispose();
865
866 if (countApplets() == 0) {
867 appletSystemExit();
868 }
869 }
870 }).start();
871 }
872
873 /**
874 * Exit the program.
875 * Exit from the program (if not stand alone) - do no clean-up
876 */
877 private void appletSystemExit() {
878 if (factory.isStandalone())
879 System.exit(0);
880 }
881
882 /**
883 * Quit all viewers.
884 * Shutdown all viewers properly then
885 * exit from the program (if not stand alone)
886 */
887 protected void appletQuit()
888 {
889 // The caller thread is event dispatch thread, so
890 // spawn a new thread to avoid blocking the event queue
891 // when calling appletShutdown.
892 //
893 new ManagedLocalsThread(new Runnable()
894 {
895 @Override
896 public void run()
897 {
898 for (Enumeration<AppletPanel> e = appletPanels.elements() ; e.hasMoreElements() ;) {
899 AppletPanel p = e.nextElement();
900 appletShutdown(p);
901 }
902 appletSystemExit();
903 }
904 }).start();
905 }
906
907 /**
908 * Handle events.
909 */
910 public void processUserAction(ActionEvent evt) {
911
912 String label = ((MenuItem)evt.getSource()).getLabel();
913
914 if (amh.getMessage("menuitem.restart").equals(label)) {
915 appletRestart();
916 return;
917 }
918
919 if (amh.getMessage("menuitem.reload").equals(label)) {
920 appletReload();
921 return;
922 }
923
924 if (amh.getMessage("menuitem.clone").equals(label)) {
|
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package sun.applet;
27
28 import java.util.*;
29 import java.io.*;
30 import java.awt.*;
31 import java.awt.event.*;
32 import java.awt.print.*;
33 import javax.print.attribute.*;
34 import java.applet.*;
35 import java.net.URL;
36 import java.net.SocketPermission;
37 import java.security.AccessController;
38 import java.security.PrivilegedAction;
39 import sun.awt.SunToolkit;
40 import sun.awt.AppContext;
41
42 /**
43 * A frame to show the applet tag in.
44 */
45 @SuppressWarnings("serial") // JDK-implementation class
46 final class TextFrame extends Frame {
47
48 /**
49 * Create the tag frame.
50 */
51 @SuppressWarnings("deprecation")
52 TextFrame(int x, int y, String title, String text) {
53 setTitle(title);
54 TextArea txt = new TextArea(20, 60);
55 txt.setText(text);
56 txt.setEditable(false);
57
58 add("Center", txt);
59
60 Panel p = new Panel();
836 p.sendEvent(AppletPanel.APPLET_STOP);
837 p.sendEvent(AppletPanel.APPLET_DESTROY);
838 p.sendEvent(AppletPanel.APPLET_DISPOSE);
839 p.sendEvent(AppletPanel.APPLET_QUIT);
840 }
841
842 /**
843 * Close this viewer.
844 * Stop, Destroy, Dispose and Quit an AppletView, then
845 * reclaim resources and exit the program if this is
846 * the last applet.
847 */
848 void appletClose() {
849
850 // The caller thread is event dispatch thread, so
851 // spawn a new thread to avoid blocking the event queue
852 // when calling appletShutdown.
853 //
854 final AppletPanel p = panel;
855
856 new Thread(null, new Runnable()
857 {
858 @Override
859 public void run()
860 {
861 appletShutdown(p);
862 appletPanels.removeElement(p);
863 dispose();
864
865 if (countApplets() == 0) {
866 appletSystemExit();
867 }
868 }
869 },
870 "AppletCloser", 0, false).start();
871 }
872
873 /**
874 * Exit the program.
875 * Exit from the program (if not stand alone) - do no clean-up
876 */
877 private void appletSystemExit() {
878 if (factory.isStandalone())
879 System.exit(0);
880 }
881
882 /**
883 * Quit all viewers.
884 * Shutdown all viewers properly then
885 * exit from the program (if not stand alone)
886 */
887 protected void appletQuit()
888 {
889 // The caller thread is event dispatch thread, so
890 // spawn a new thread to avoid blocking the event queue
891 // when calling appletShutdown.
892 //
893 new Thread(null, new Runnable()
894 {
895 @Override
896 public void run()
897 {
898 for (Enumeration<AppletPanel> e = appletPanels.elements() ; e.hasMoreElements() ;) {
899 AppletPanel p = e.nextElement();
900 appletShutdown(p);
901 }
902 appletSystemExit();
903 }
904 },
905 "AppletQuit", 0, false).start();
906 }
907
908 /**
909 * Handle events.
910 */
911 public void processUserAction(ActionEvent evt) {
912
913 String label = ((MenuItem)evt.getSource()).getLabel();
914
915 if (amh.getMessage("menuitem.restart").equals(label)) {
916 appletRestart();
917 return;
918 }
919
920 if (amh.getMessage("menuitem.reload").equals(label)) {
921 appletReload();
922 return;
923 }
924
925 if (amh.getMessage("menuitem.clone").equals(label)) {
|