Java
Swing - GUIs LESSON NOTE APPLICATIONS Many
applications, notably games, require that we have some aspects that are
animation. However, we also need to
have other components such as buttons and text fields. Finally, we need to be able to switch
components in and out as needed. EXAMPLE 1 – PAUSING AN
ANIMATION This
example takes the bouncing ball example from the previous lesson and includes
a button that makes it possible to pause/unpause the application. The
button is added in the specialized JFrame class. It is added to the content pane before the
specialized panel is added. Remember
that the specialized JPanel animates based on the timer's event. So, if we stop the time, we stop the
animating. The button's job is simply
to stop and start the timer as it is clicked. The
specialized JPanel class is unchanged.
EXAMPLE 2 – CHOOSING DIFFERENT
ANIMATION PANELS Coming
soon. L |
||
|