importjava.applet.*;importjava.awt.*;publicclassShapesextendsApplet{int x =300, y =100, r =50;publicvoidpaint(Graphics g){
g.drawLine(30,300,200,10);
g.drawOval(x-r,y-r,100,100);
g.drawRect(400,50,200,100);}}
结果
上面的代码示例将在启用 java 的 Web 浏览器中产生以下结果。
A line ,Oval& a Rectangle will be drawn in the browser.