The basics of Java drawing: Draw a circle

Source: Internet
Author: User

/**
* 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,);
 }
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.