A small Map edited by Java

Source: Internet
Author: User

After reading the book, I wrote it ..

Import java. AWT .*;
Import java. AWT. Geom .*;
Import javax. Swing .*;

Public class map extends jframe {
 
Public map (){
Super ("map ");
Setsize (350,300 );
Setdefaclocloseoperation (jframe. exit_on_close );
Mappane map = new mappane ();
Container content = getcontentpane ();
Content. Add (MAP );
Show ();
}
 
Public static void main (string arguments []) {

Map frame = new map ();
}
}

Class mappane extends jpanel {
 
Public void paintcomponent (Graphics comp ){
Graphics2d comp2d = (graphics2d) comp;
Comp2d. setcolor (color. Blue );
Rectangle2d. Float background = new rectangle2d. Float (0f, 0f, (float) getsize (). Width, (float) getsize (). Height );
Comp2d. Fill (background );
Comp2d. setcolor (color. White );
Basicstroke pen = new basicstroke (2f, basicstroke. cap_butt, basicstroke. join_round );
Comp2d. setstroke (PEN );
For (int ax = 0; ax <340; AX + = 10)
For (INT ay = 0; ay <340; Ay + = 10 ){
Arc2d. Float wave = new arc2d. Float (ax, ay, 10, 10, 0,-180, arc2d. Open );
Comp2d. Draw (wave );
}

Gradientpaint Gp = new gradientpaint (0f, 0f, color. Green, 350f, 350f, color. Orange, true );
Comp2d. setpaint (GP );
Generalpath FL = new generalpath ();
Fl. moveTo (10f, 12f );
Fl. lineto (234f, 15f );
Fl. lineto (253f, 25f );
Fl. lineto (261f, 71f );
Fl. lineto (344f, 209f );
Fl. lineto (336f, 278f );
Fl. lineto (295f, 310f );
Fl. lineto (259f, 274f );
Fl. lineto (205f, 188f );
Fl. lineto (211f, 171f );
Fl. lineto (195f, 174f );
Fl. lineto (191f, 118f );
Fl. lineto (120f, 56f );
Fl. lineto (94f, 68f );
Fl. lineto (81f, 49f );
Fl. lineto (12f, 37f );
Fl. closepath ();
Comp2d. Fill (FL );

Comp2d. setcolor (color. Black );
Basicstroke pen2 = new basicstroke ();
Comp2d. setstroke (pen2 );
Ellipse2d. Float e1 = new ellipse2d. Float (235,140 );
Ellipse2d. Float e2 = new ellipse2d. Float (225,130 );
Ellipse2d. Float E3 = new ellipse2d. Float (245,130 );
Comp2d. Fill (E1 );
Comp2d. Fill (E2 );
Comp2d. Fill (E3 );
}
}

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.