Graphics Programming Exercise

This exercise is in lieu of a Graphics lab. There is nothing to hand in. Work through the steps and ask your teacher or another student if you need help understanding something.

Remember the "Three Steps to GUI Programming" that we covered last week:

  1. Make a background window
  2. Put Components into the window
  3. Add Listeners to the Components

The Graphics experiments we are doing here allow us to create our own custom UI widgets, which would be used in Step 2 above.

Some examples

Here are two examples of basic custom UIs. Copy each to a local file and run them. Change at least two variables or functions in each to see how they work.

RectWindow.java demonstrates how the component figures out the size of its own window. Run this program and resize the window. Make some changes to figure out how it works. Try 2-3 of these:

Ripple.java demonstrates how to set up animation. Make some changes to figure out how it works. Try 2-3 of these:

Next Steps

The best way to learn about code is by playing with it. Pick one of the following tasks and implement it as your own custom UI widget. Use the above examples as a starting point.