End of the Chapter

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
Historical topic: Java appletsModern web browsers do not run Java applets. The Applet API was deprecated for removal before Java 25 and was removed in Java 26. Treat applet examples on this page as historical object-oriented/GUI examples; for new desktop interfaces use Swing where appropriate or JavaFX/OpenJFX.

Say that the Graphics object grph has a drawing area of width=200 and height=150. Fill in the blanks so that a line is drawn from the lower left corner to the upper right corner of the area.

Answer:

grph.drawLine(  0, 149, 199, 0 )

Since the height is 150, and the numbering of pixels starts at zero, the Y coordinate of the lower left corner is 149.

End of the Chapter

You may wish to browse through the following. Click on a subject that interests you to go to where it was discussed.

The next chapter has more examples of applets and graphics.

You have reached the end of the chapter.

go to previous page   go to home page