Lecture Introduction to Java programming - Chapter 18: Applets and multimedia

In this chapter, you will learn how to write Java applets, explore the relationship between applets and the Web browser, and discover the similarities and differences between applications and applets. You will also learn how to create multimedia Java applications and applets with images and audio. | Chapter 18 Applets and Multimedia Motivations When browsing the Web, you frequently see the graphical user interface and animation developed using Java. These programs are called Java applets. Suppose you want to develop a Java applet for the Sudoku game. How do you write this program? Sudoku Objectives To convert GUI applications to applets (§). To embed applets in Web pages (§). To run applets from Web browsers and from the appletviewer (§§). To write a Java program that can run as both an application and an applet (§). To override the init, start, stop, and destroy methods in the Applet class (§). To pass string values to applets from HTML (§). To develop an applet for the TicTacToe game (§). To develop an animation for a bouncing ball (§). To locate resources (images and audio) using the URL class (§). To play audio in any Java program (§). Developing Applets The HTML Tag First Simple Applet Java Applet Demo DisplayLabel Run Applet Viewer Applications vs. Applets Similarities Since JFrame and JApplet both are subclasses of the Container class, all the user interface components, layout managers, and event-handling features are the same for both classes. Differences Applications are invoked from the static main method by the Java interpreter, and applets are run by the Web browser. The Web browser creates an instance of the applet using the applet’s no-arg constructor and controls and executes the applet through the init, start, stop, and destroy . | Chapter 18 Applets and Multimedia Motivations When browsing the Web, you frequently see the graphical user interface and animation developed using Java. These programs are called Java applets. Suppose you want to develop a Java applet for the Sudoku game. How do you write this program? Sudoku Objectives To convert GUI applications to applets (§). To embed applets in Web pages (§). To run applets from Web browsers and from the appletviewer (§§). To write a Java program that can run as both an application and an applet (§). To override the init, start, stop, and destroy methods in the Applet class (§). To pass string values to applets from HTML (§). To develop an applet for the TicTacToe game (§). To develop an animation for a bouncing ball (§). To locate resources (images and audio) using the URL class (§). To play audio in any Java program (§). Developing Applets The HTML Tag
Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.