Import java.awt.*
Import javax.swing.*
/**
* <p>title: Drawing of basic graphics </p>
* <p> Description: This example demonstrates the drawing of basic graphics such as quadrilateral, rounded rectangles, ellipses, and so on. </p>
* <p>copyright:copyright (c) 2003</p>
* <P>FILENAME:SAMPLE.JAVA</P>
* @ Version 1.0
*/
public class Sample extends JFrame {
/**
*<br> Method Description: Main method
*<br> input parameters:
*< br> return type:
/
public static void Main (string[] args) {
Sample SL = new sample ();
Sl.update ();
}
/**
*<br> method Description: Builder, displaying form
*<br> input parameters:
*<br> return type:
/
Sample () {
Super ( "Sample");
Setdefaultcloseoperation (jframe.dispose_on_close);
SetSize (310,160);
Show ();
}
/**
*<br> Method Description: Update screen
*<br> input parameters:
*<br> return type:
*/
public void Update () {
Repaint ();
}
/**
*<br> Method Description: Drawing screen
*<br> input parameters:
*<br> return type:
/
public void paint (Graphics G{
int [] x={10,30,80,50,10};
int [] y={90,140,120,100,90};
G.setcolor (Color.cyan);
//Draw a vertical bar
for (int i=0; i<=300; i+=10) {
G.drawline (i,0,i,150);
//Draw horizontal bars
for (int i=0; i<=150; i+=10) {
G.drawline (0,i,300,i);
}
G.setcolor (Color.Black);
//Angled Rectangle, starting point (10,30), width 80, height
G.drawrect (10,30,80,50);
Rounded Rectangle, starting point (110,30), width 80, height 50, angle (a=20,b=10)
G.drawroundrect (110,30,80,50,20,10);
Multi-corner
G.drawpolygon (x,y,5);
Ellipse, center of the Circle (110,90), a=80,b=50
G.drawoval (110,90,80,50);
An arc, the center of the Circle (219,30), the a=80,b=50 angle between 0-90
G.drawarc (210,30,80,50,0,90);
Slices, center (219,90), a=80,b=50 angle between 0-90
G.fillarc (210,90,80,50,0,90);
}
}