Basics

In this part of the Java 2D games tutorial, we will write about some
basics needed to create games. We create a basic application, paint
a donut, and display a picture.

About

This is Java 2D games tutorial. It is aimed at beginners. This tutorial will
teach you the basics of programming 2D games in Java programming language and
Swing GUI toolkit. Images used in this tutorial can be downloaded
here.

We determine the width and height of the image. The preferred size of the
board panel is set to the dimensions of the image. In cooperation with
the JFrame'spack() method, the window is just
big enough to show the image.