Java Dynamictaichi (Collation)

Source: Internet
Author: User
Tags cos sin

1  Packagedemo;2 3 ImportJava.awt.Color;4 ImportJava.awt.Graphics;5 6 ImportJavax.swing.JFrame;7 ImportJavax.swing.JPanel;8 9 /**Ten * Java Dynamictaichi (collation) One  * A * 2016-1-2 Shenzhen Nanshan Ping Shan village Zengjianfeng -  */ -  the  Public classDynamictaichiextendsjpanel{ -     Private Static Final LongSerialversionuid = 1L; -     /* - * All data are changed proportionally according to CenterX, so + * If you want to change the size of the panel, you can modify the CenterX value directly. -      */ +     Static intCenterX = 600/2; A     Static intCenterY =CenterX; at     Static intCicle =CenterX; -     Static intAngle = 0; -      -      PublicDynamictaichi () { - start (); -     } in     Private voidstart () { -         NewThread (NewRunnable () { to              + @Override -              Public voidrun () { the                  while(true) { *                     Try { $angle++;Panax NotoginsengThread.Sleep (10); - repaint (); the}Catch(Exception e) { + e.printstacktrace (); A                     } the                 } +                  -             } $ }). Start (); $     } - @Override -      Public voidPaint (Graphics graphics) { the         Super. Paint (graphics); -          This. SetBackground (color.red);Wuyi Graphics.setcolor (color.white); theGraphics.fillarc (CENTERX-CICLE/2, CENTERY-CICLE/2, cicle, cicle, Angle, 180); - Graphics.setcolor (color.black); WuGraphics.fillarc (CENTERX-CICLE/2, CENTERY-CICLE/2, Cicle, Cicle, 180+angle, 180); -Graphics.fillarc (centerx+ (int) (Cicle/2/2* (Math.Cos (angle*math.pi/180)))-CICLE/2/2, centery-(int) (Cicle/2/2* (Math.sin (angle*math.pi/180))-CICLE/2/2, CICLE/2, CICLE/2, 0, 360); About Graphics.setcolor (color.white); $Graphics.fillarc (centerx+ (int) (Cicle/2/2* (Math.Cos ((angle+180) *math.pi/180))-CICLE/2/2, centery-(int) (Cicle/2/2* (Math.sin ((angle+180) *math.pi/180))-CICLE/2/2, CICLE/2, CICLE/2, 0, 360); - Graphics.setcolor (color.black); -Graphics.fillarc (centerx+ (int) (Cicle/2/2* (Math.Cos ((angle+180) *math.pi/180))-CICLE/2/2/2, centery-(int) (Cicle/2/2* (Math.sin ((angle+180) *math.pi/180))-CICLE/2/2/2, CICLE/2/2, CICLE/2/2, 0, 360); - Graphics.setcolor (color.white); AGraphics.fillarc (centerx+ (int) (Cicle/2/2* (Math.Cos (angle*math.pi/180)))-CICLE/2/2/2, centery-(int) (Cicle/2/2* (Math.sin (angle*math.pi/180))-CICLE/2/2/2, CICLE/2/2, CICLE/2/2, 0, 360); +     } the      -      Public Static voidMain (string[] args) { $JFrame JFrame =NewJFrame (); theJframe.settitle ("Dynamictaichi"); theJframe.setsize (centerx*2, centery*2); the jframe.setdefaultcloseoperation (jframe.exit_on_close); theJframe.setlocationrelativeto (NULL); -          inDynamictaichi JPanel =NewDynamictaichi (); the Jframe.add (jPanel); the          AboutJframe.setvisible (true); the     } the}

Java Dynamictaichi (Collation)

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.