Introduction to graphics programming in Java

      by Mads Rosendahl

Writing graphics applications in Java using Swing can be quite a daunting experience which requires understanding of some large libraries, and fairly advanced aspects of Java. In these notes we will show that by using a small subset of the Swing package we can write a wide range of graphics programs. To make this possible we have constructed three small classes that simplifies three of the more complex aspects of graphics programming: 2D-graphics, layout of components, and event-handling.

The notes are written for an introductory programming course. Most of the examples just uses a single main method and can be understood early in such a course. Some of the later examples contains other static methods and in some final examples we define some classes.

Below you will find links to the notes, the classes, documentation and examples for download

The lecture notes

Introduction to graphics programming in Java

Source code for JCanvas, JBox and JEventQueue

class JCanvas
class JBox
class JEventQueue

API (documentation)

API for JCanvas, JBox and JEventQueue

Examples

browse catalog
ProgramDescricption
EmptyFrame.java[section 1.0]
DrawCanvas.java[section 2.0]
CheckImage.java[section 2.5]
CheckLabel0.java[section 3.2]
CheckSize1.java[section 3.2]
CheckButton.java[section 3.5]
CheckTextField1.java[section 3.7]
CheckSpinner.java[section 3.8]
CheckProgress.java[section 3.8]
CheckComboList.java[section 3.9]
CheckBorders1.java[section 3.11]
CheckAddRemove.java[section 3.13]
CheckListener1.java[section 4.1]
CheckListener2.java[section 4.1]
CheckListener3.java[section 4.1]
CheckState.java[section 4.2]
CheckTextComp.java[section 4.3]
CheckMouse.java[section 4.4]
CheckTimers.java[section 4.5]
CheckMenus.java[section 4.6]
CheckClose.java[section 4.7]
SlideShow.java[section 5.1]
BounceBall1.java[section 5.1]
BounceBall3.java[section 5.1]
BounceBall.java[section 5.2]
RollBackground.java[section 5.3]
CheckFontCanvas.java[section 6.0]
 
Minesweep.java
Snake.java