Đang chuẩn bị liên kết để tải về tài liệu:
Introduction to Java: 14 And Then There Were Applets
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Tham khảo tài liệu 'introduction to java: 14 and then there were applets', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 14 In this chapter What s a Java Applet AudioClip Interface AppletContext Interface AppletStub Interface Audio in Applications And Then There Were Applets Although it is not part of the java.awt package the java.applet package is closely related. The java.applet package provides support for running an applet in the context of a World Wide Web browser. It consists of one class Applet and three interfaces AppletContext AudioClip and Appletstub . The Applet class supports the applet life cycle methods init start stop destroy that you override to write an applet. AudioClip provides support for audio within applets. Applications use the sun.audio package for audio support sun.audio is also covered in this chapter. The Appletstub and AppletContext interfaces provide a way for the applet to interact with its run-time environment. Many of the methods of Appletstub and AppletContext are duplicated in the Applet class. 14.1 What s a Java Applet Much of the initial excitement about Java centered around applets. Applets are small Java programs that can be embedded within HTML pages and downloaded and executed by a web browser. Because executing code from random Internet sites presents a security risk Java goes to great lengths to ensure the integrity of the program executing and to prevent it from performing any unauthorized tasks. An applet is a specific type of Java Container. The class hierarchy of an applet is shown in Figure 14-1. When you are writing an applet remember that you can use the features of its ancestors. In particular remember to check the methods of the Component Container and Panel classes which are inherited by the Applet class. 470 14.1 What s a Java Applet 471 Figure 14 1 Applet class hierarchy 14.1.1 Applet Methods All the methods of Applet except setStub either need to be overridden or are methods based on one of the java.applet interfaces. The system calls setStub to set up the context of the interfaces. The browser implements the AppletContext and .