Chapter 2 Applet exercises

xiaoxiao2021-03-06  68

/ * * To place this applet in a web page, * add the html document for the page. * * // / AWT and Swing together comprise the collection of // classes used for building graphical Java programs import java.awt *;. // required for programs that drawimport javax.swing *;. // required for Swing applets public class FirstApplet extends JApplet { Public void Paint (Graphics G) {// Draw a line from the Upper Left Corner to // 100 Pixels Below The Top Center of The Applet G.drawline (0, 0, 250, 100); // Draw A Line from The End of the previous line // up to the top center of the applet g.drawline (250, 100, 250, 0); // Draw An Oval INSCRIBED INVINVISIBLE // Rectangle with ITS Upper Left Corner At the // INTERSECTION Of The Two Lines Drawn Above G.drawoval (250, 100, 200, 100);}}

Compile first, then view it through AppletViewer. To view the web mode, pay attention: If it is open in IE, IE's attribute → Advanced → Java → uses Java 2 v1.4.2 for must hook. If it is a multi-window browser using the IE kernel like Myie, set their Java virtual machine settings.

转载请注明原文地址:https://www.9cbs.com/read-83552.html

New Post(0)
CopyRight © 2020 All Rights Reserved
Processed: 0.039, SQL: 9