1 / 6

JAVA: Chapter 4 Applet & Advanced Graphic, Multimedia, input & output

JAVA: Chapter 4 Applet & Advanced Graphic, Multimedia, input & output. Learning Outcome. At the end of this slide, student able to: Applet & Advanced Graphic Learn how the Web browser controls and executes the applet Learn how to handle mouse events and keystrokes

brosh
Download Presentation

JAVA: Chapter 4 Applet & Advanced Graphic, Multimedia, input & output

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. JAVA: Chapter 4 Applet & Advanced Graphic, Multimedia, input & output

  2. Learning Outcome At the end of this slide, student able to: Applet & Advanced Graphic Learn how the Web browser controls and executes the applet Learn how to handle mouse events and keystrokes Multimedia, input & output Develop multimedia applications with audio and images. Understand input and output streams

  3. Applets Applet is file that can used as Graphical User Interface (GUI) inside webpage.

  4. Applets 1. Install jxpiinstall.exe and set as medium security 2. Create New project (to create applets file) 3. Create new java inside that project and clean & debug (to create .jar file) package javaapplication5; import javax.swing.*; public class JavaApplication5 extends JApplet{ public JavaApplication5() { add(new JLabel("Great!", JLabel.CENTER)); } } 4. Create New project (to create html file) 5. Copy .jar file and paste into current project. 6. Create html file: <html> <head> <title>Java Applet Demo</title> </head> <body> <applet code="javaapplication5.JavaApplication5" archive="JavaApplication5.jar"></applet> </body> </html> 7. Open html file using firefox.

  5. Applets

  6. Input/Output package javaapplication8; // DataInputStream, DataOutputStream, IOException /* * TestDataStream.java * * $Id:$ * * $Log:$ */ /* * A sample program that works with the DataStream classes * and demonstrates Binary I/O * * @author Liang-16.8 */ import java.io.*; // DataInputStream, DataOutputStream, IOException public class JavaApplication8 { public static void main(String args[]) throws IOException { // Create data output stream DataOutputStream output = new DataOutputStream(new FileOutputStream("temp.dat")); // Write out some data output.writeUTF("John"); output.writeDouble(85.5); output.writeUTF("Jim"); output.writeDouble(185.5); output.writeUTF("George"); output.writeDouble(105.25); // Close the output stream output.close(); // Create data input stream for the file DataInputStream input = new DataInputStream(new FileInputStream("temp.dat")); // Print student scores for (inti=0; i<3; i++) { System.out.println(input.readUTF() + " " + input.readDouble()); } // Close the input stream input.close(); } // main } // TestDataStream

More Related