Advanced animations on core Swing components – part II

July 9th, 2007

The first part showed the animations added (among the rest) on menus, sliders, tables and table headers. While all of these operated on the control background (except the sliders, which don’t really have background and foreground), this is not always the case. Take, for example, the Business Black Steel skin:

Note that this skin (like a few others i mentioned before) uses a header painter (painter that paints not only the title pane, but also other parts of the frame, such as menu bar, toolbar, task panes, status bars etc). With the specific skin, the header painter uses dark background, which requires using light foreground colors in order for the menu texts to be legible (note how all other controls use dark foreground on light background gradients). And here comes the twist – in order to keep the rollover effects consistent (black on steel blue), it’s not enough to animate the background of the top-level menus (which would result in white texts on steel blue background instead of black texts on steel blue background). In addition, the painting of menus depends on the menu parent (menu bar or not):

As you can see in this screenshot, non top-level menus and menu items use the main theme (black text on white background / black text on steel blue background for active states), while the top-level menus use different dark-light combinations based on the menu state.

Which brings me to the main animation effect that i’m going to show in this entry – the top-level menus animate not only the background fill, but also the foreground color (otherwise the animation would look inconsistent, switching the foreground color to black at the beginning, which would result in a very distracting animation sequence). Here is how it looks like under slow animation speed (note the rollover effects on the top-level menus):




And here is how the same animation sequences look under the default speed settings:



So, you’re welcome to grab the latest binary drops of version 4.0dev and try the new and improved Business Black Steel skin.