/**
* Basic principles of Java drawing: Draw a circle
* @author TFQ
* @date 2011-08-27
*/
Import javax.swing.*;
Import java.awt.*;
public class Drawcicle extends jframe{
Mypanel Mp=null;
public static void Main (string[] args) {
Drawcicle dc=new drawcicle ();
}
Public Drawcicle () {
MP =new Mypanel ();
This.add (MP);
This.setsize (300, 250);
This.setlocation (600, 300);
This.setdefaultcloseoperation (this. Exit_on_close);
This.setvisible (TRUE);
}
}
/**
* A panel of paint and also displays
* @author tfq
*
*/
Class Mypanel extends jpanel{
&N Bsp
/**
* Overlay JPanel Paint () method
* Graphics a brush class equivalent to drawing
* Paint make up the call when the current panel is initialized, and the window changes to an hour is invoked,
*/
public void Paint (Graphics g) {
//invoke the parent class function to complete initialization
is also invoked when the window is maximized to minimize //This sentence cannot be less
super.paint (g);
system.out.println ("piant () called!");
//First draw a circle
//g.drawoval (Ten, a);
//draw a line
// G.drawline (10, 20, 100, 20);
//The first parameter represents the x-axis distance from the upper-left corner of the current form, the second parameter represents the y-axis distance from the upper-left corner of the current form, and the third fourth represents the width of the rectangle
//g.drawrect (0, 0, 50, 60);
//fills rectangular color
g.setcolor (color.green);
g.fillrect (0, 0,);
}
}