Java Swing Graphics

This course assumes that you already know how to program in Java. Perhaps you’ve take my Intro to programming course.
It is focused on teaching the core features of Swing: how to use it and make useful programs. It is not a typical second computer programming course as we're not learning data structures etc (see last paragraph).

From personal experience I believe that mentoring is one of the best ways to learn, so this course will be run using Slack. It will be interactive: lessons and instructions will be posted there, and you can ask questions and I’ll answer them, help you when you’re stuck , etc. I think that this is better than just watching a bunch of videos. The other good thing about this, is that when you ask questions, others can answer them too – since I won’t be online 24/7 .

I can probably handle somewhere between 25 and 40 people in this course.

My credentials
I’ve been teaching Java programming to high school students for about 10 years now. I've worked with Swing a lot and know which parts are the most useful. There are parts of Swing that I don't use. I teach my students everything they need to make turnbased and realtime games using Swing.
Most of my online projects though are PHP based (https://demo.iquark.ca), but I don’t know PHP well enough to teach it. You can see some of my Java stuff at https://github.com/salamander2/functionID and other repositories there. (We’ll be going over a lot of the content found on Salamander2)

Time commitment
It’s hard to estimate this. I think that about 10 hours a week, though you could probably do it with less. Also, I’ll need regular feedback about pacing – am I going too slowly or too fast?

Duration
I don’t really know. It depends on the pacing. I've added the approximate number of hours to do each lesson. At 22 hours + the final project, it looks like this will take 3 weeks.

Free? Yes. Why?

This course really is free. Normally I teach in a classroom, so I'm still learning about how to package this online. It won't be 100% slick, but that's okay. I would like to eventually offer this as a paid course online. (A paid course means that people are likely to be more committed and less likely to quit for no reason.) All that I want from you is to tell me what works well and what needs improving.

I recommend using Eclipse IDE, but you can use another if you wish.
Everything we do can be done with Java 8. We don’t need and won’t be learning the latest and newest additions. (See the final paragraph on this page.)

Course topics

● = subtopic
► = assignment to do
(approx hours in parentheses)

  1. Install Eclipse (0-1 hr)
  2. Unit 1

  3. JFrame and JPanel (1 hr)
    Note about JFrames and JPanels. How to add JButtons and JLabels. How to make your own (subclassing).
  4. Swing Timers (1 hr)
    ● how to stop a timer. Not covered: deadlocks
    ► add buttons using a timer. Stop the timer when you get to 20 buttons on the screen.
    ● JOptionPanes (extra topic)
  5. Layout Managers (2-3 hrs)
    1. FlowLayout, GridLayout, BorderLayout
      ► BorderLayout: 5 different coloured JPanels + a label in each
    2. JTextfield - introduce this for use later on
    3. MigLayout
      ► Make a GUI using MigLayout

    Unit 2

  6. Events and event listeners: action, key, mouse (1 hr)
    ► one button toggles BG color, the other moves the first button
    ► Making a JMenu ?
  7. Drawing on JPanel
    1. drawing commands (2 hrs)
      ● line, rectangle, oval, colour
      ● Graphics2D: stroke, antialias
    2. ► equation plotter (1 hr)
      pixel graphics, Optional: Mandlebrot set
    3. key, mouse events (2 hrs)
      ► draw lines from centre to mouse, or that cool line program
      ► move spaceship and fire using keys
    4. saving image, loading image (< 1hr)
      If time permitted, making a paint program would go here
  8. Unit 3

  9. Data storage considerations (< 1hr)
    tictactoe, minesweeper, breakout, rush hour
  10. Grid based games, 2D arrays (3 hrs)
    Make TicTacToe together
    Resizing screen (if not done with equation plotter)
  11. Extend to your own game (3+ hrs)
    ► Program something like Connect 4, Minesweeper, Colour Flood, Othello, Go, Rush Hour
  12. Unit 4

  13. Animated games (objects) (2-3 hrs)
    Moving a ball
    1. collisions
      a. against walls
      b. against paddle
      c. against stationary rectangle
      d. two moving circles/rectangles of different sizes
    Breakout game program is explained online.
  14. Rotations (< 1 hr)
    Demonstrate both ways (using a timer): rotation matrix and g2d.rotate.
    ► program an analog clock display
    If we had time, this is where the loading icon project would happen
  15. Create your own game. (?? hrs)
    ► space invaders type game
    ► or zombie attack, using Git to work in teams programming the game.
    This is a top down game. The player is in the centre of the screen. Zombies are created at random points in a circle (off screen) and move towards the player. When the player moves, the background should move in such a way that the player remains centred in the screen. Add ability to shoot zombie. Add buildings as obstacles. (Feel free to replace zombie with anything else - duck attack ... etc.) --- Nope, this will take too much time
  16. Inheritance (1 hr)
    ► use inheritance to make different weapon types or enemy types.

— The end for now —

In terms of data structures, this course doesn't teach much about them. We learn objects and 2D arrays. For the space invaders project we'll use arraylists. Hashmaps are not needed, but would come in handy for a text-adventure game. Enums may be handy but also are not needed.
There's also no reason to learn sorting algorithms, trees, lists, queues, etc. for the graphics projects that we're doing. We also don't learn about lambdas, streams, NIO, sockets, etc.