Tutorial/Flags/1 Rectangles

From Progzoo
Jump to: navigation, search


The flag of Libya is a simple green rectangle.

Try the program as it is given, then change it so that the green rectangle is 150 wide. Flaglibya.png

[Font] [Default] [Show] [Resize] [History] [Profile]


The flag of France is blue, white and red. The code given draws only one of the three rectangles required, and it is in the wrong place.
Flag guide france.png

[Font] [Default] [Show] [Resize] [History] [Profile]


The flag of Germany is black, red and yellow.

Only one of the three rectangles has been drawn - and that one is in the wrong place. Flaggermany.png

[Font] [Default] [Show] [Resize] [History] [Profile]


  • The flag of Palau is a yellow circle on a blue background.
  • The rectangle is 150 by 100.
  • The circle is in position 25,25, width and height are 50,50.
  • The RGB values for the blue: 154,176,217. Use the phrase:
g.setColor(new Color(154,176,217));
  • The dark lines are NOT part of the flag. They are shown as guides only.

In order to draw a circle we need to track down a method of Graphics or Graphics2D. There is no fillCircle method - but you should find something else that will do the job.

[Font] [Default] [Show] [Resize] [History] [Profile]