Chapter 19. Drawing in a Window

In this chapter you'll look at how you can draw using the Java 2D facilities that are part of the Java Foundation Classes (JFC). You'll explore how you draw in an applet and in an application. You'll investigate how you can combine the event-handling capability that you learned about in the previous chapter with the drawing facilities you'll explore in this chapter to implement an interactive graphical user interface for creating a sketch.

By the end of this chapter you will have learned:

  • What components are available for creating a GUI

  • How coordinates are defined for drawing on a component

  • How you implement drawing on a component

  • How to structure the components in a window for drawing

  • What kinds of shapes you can draw on a component

  • How you implement mouse listener methods to enable interactive drawing operations

Get Ivor Horton's Beginning Java™ 2, JDK™ 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.