Layering GUI items |
When we have too many GUI components at the top or bottom of the window, it can be quite difficult to find the one you want. We can use objects of type Container to keep them organized.
See the program FallingBall. It allows us to control various aspects of a falling ball.
It has a color menu as before, but also three buttons to control the speed. Notice how each has associated a handler with a mouse press.
Finally at the end, notice the way we create three containers for GUI components. The container row1 holds the color menu, while row2 holds the three buttons to control the speed. These two are put into container bottomBox (arranged vertically) and then bottomBox is added to the bottom of the window.
Check out the "GUI in Grace" specification in the documentation section of the course web page for a good summary of how to use GUI components in your program!
Layering GUI items |