// create a window with an animating sheet
// copy over its contents from the temp window
// animate it
// when done, remove animating sheet and add real contents
showX = x;
startY = desktopBounds.y + desktopBounds.height;
ActionListener animationLogic = new ActionListener() {
public void actionPerformed(ActionEvent e) {
long elapsed =
System.currentTimeMillis() - animationStart;
if (elapsed > ANIMATION_TIME) {
// put real contents in window and show
window.getContentPane().removeAll();
window.getContentPane().add (contents);
window.pack();
window.setLocation (showX,
startY - window.getSize().height);
window.setVisible(true);
window.repaint();
animationTimer.stop();
animationTimer = null;
} else {
// calculate % done
float progress =
(float) elapsed / ANIMATION_TIME_F;
// get height to show
int animatingHeight =
(int) (progress * tempWindowSize.getHeight());
//System.out.println ("animatingHeight " +
// animatingHeight);
animatingHeight = Math.max (animatingHeight, 1);
animatingSheet.setAnimatingHeight (animatingHeight);
window.pack();
window.setLocation (showX,
startY - window.getHeight());
window.setVisible(true);
window.repaint();
}
}
};
animationTimer =
new Timer (ANIMATION_DELAY, animationLogic);
animationStart = System.currentTimeMillis();
animationTimer.start();