Starting from:

$30

EE328-Project 5: Simple GUI Programming Solved

1.1 DESCRIPTION
Write a program that displays the Olympic rings. Make the rings colored in the Olympic colors like below:

 

If you like to make it fancier, you can add "USA" on top the rings (not required), like following:

 

You are not required to draw exactly the same as in the pictures. Anything looks similar is fine.

And the color in the intersection part of the rings is not strictly required.

2 ALGORITHM
2.1 DRAW CIRCLES
By extending JFrame we are able to use varieties of methods to draw pictures. When setVisible(true) is executed, paint(Graphics g will be executed automatically. In this method we use drawOval() to draw circles with set locations. In the meantime setColor() is used to change color of different circles. drawString() is used to print strings as well.

1

 

Figure 3.1: Screenshot of GUI Programming

2.2 DETAILS IN IMPLEMENTATION
At first the stroke of the circle is too thin to be similar to Olympic Rings. After referring to some websites I convert the object Graphics to Graphics2D to use the method setStroke(). Then the thickness of the circle can be modified.

3 RESULTS
3.1 ENVIRONMENT
•   Windows 10

•   Java Development Kit 1.8.0_131

•   Eclipse

3.2 SCREENSHOTS OF THE RESULT

We use command line to compile and execute the program. The result is shown in Fig. 3.1.

3.3 THOUGHTS
GUI programming is interesting. And with Java this process becomes much easier.

More products