// Updating border and icon
updateBorder ();
updateIcon ( radioButton );
// Background fade animation
bgTimer = new WebTimer ( "WebRadioButtonUI.bgUpdater", 40, new ActionListener ()
{
@Override
public void actionPerformed ( final ActionEvent e )
{
if ( rollover && bgDarkness < MAX_DARKNESS )
{
bgDarkness++;
c.repaint ();
}
else if ( !rollover && bgDarkness > 0 )
{
bgDarkness--;
c.repaint ();
}
else
{
bgTimer.stop ();
}
}
} );
mouseAdapter = new MouseAdapter ()
{
@Override
public void mouseEntered ( final MouseEvent e )
{
rollover = true;
if ( isAnimated () )
{
bgTimer.start ();
}
else
{
bgDarkness = MAX_DARKNESS;
c.repaint ();
}
}
@Override
public void mouseExited ( final MouseEvent e )
{
rollover = false;
if ( isAnimated () )
{
bgTimer.start ();
}
else
{
bgDarkness = 0;
c.repaint ();
}
}
};
radioButton.addMouseListener ( mouseAdapter );
// Selection changes animation
checkTimer = new WebTimer ( "WebRadioButtonUI.iconUpdater", 40, new ActionListener ()
{
@Override
public void actionPerformed ( final ActionEvent e )
{
if ( checking && checkIcon < CHECK_STATES.size () - 1 )