long totalTime = currentTime - cycleStart;
if (totalTime > MOVE_TIME) {
cycleStart = currentTime;
}
float fraction = (float) totalTime / MOVE_TIME;
fraction = Math.min(1.0f, fraction);
fraction = 1 - Math.abs(1 - (2 * fraction));
animate(fraction);
}
public static void main(String[] args) {
final JFrame frame = new JFrame();
frame.setLayout(new BorderLayout());
frame.setSize(400, 70);
frame.getContentPane().add(new AutoComponent());
frame.setUndecorated(true);
XUtil.setComponentCenter(frame);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
frame.setVisible(true);
}
});
}
}