Draw a circle using the Java drawing class graphics

Source: Internet
Author: User


Code:

Package com.dikea.demo01;

Import java.awt.*;
Import javax.swing.*;
Java Drawing principle Public

class demo_01  extends JFrame {
	Mypanel MP = null;
	public static void Main (string[] args) {

		//TODO automatically generated method stub
		demo_01 demo01 = new demo_01 ();
	}
	
	Public demo_01 () {
		MP = new Mypanel ();
		This.add (MP);
		
		This.setsize (in);
		This.setdefaultcloseoperation (jframe.exit_on_close);
		This.setvisible (True);
	}


Defines a mypanel panel for drawing area
class Mypanel extends jpanel{//
	overlay JPanel
	//Graphics is an important class of drawings that can be understood as a brush
	public void Paint (Graphics g) {
		// 	1. Call the parent class function to complete the initialization task
		//	This sentence cannot be less
		super.paint (g);
		
		First draw a circle
		g.drawoval (+,);
	}

Run Effect chart:


Related Article

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.