View Full Version : button.removeIcon()

23 Oct 2009, 12:36 AM
Just a quick question. Is it possible to remove an icon from a button?

I have something like this currently:

//this method updates the login button to show a loading wheel
public void setLoading(boolean loading) {
if (loading) {
loginButton.setIcon( IconHelper.createStyle("loading-small") ) ;
loginButton.setEnabled(false) ;
} else {
loginButton.setIcon( IconHelper.createStyle("empty",0,0) ) ;
loginButton.setEnabled(true) ;
}//end: method setLoading
This almost works except the "Login" label on the button isn't in the same place if you add the icon and then remove it again. It shifts it to the right by about 10 pixels.

My css looks like this:

.loading-small {
background: url(images/loading-small.gif) no-repeat center left !important;

.empty {
display: none ;

23 Oct 2009, 1:50 AM
loginButton.setIcon(null ) ;

that removes the icon.

23 Oct 2009, 2:18 AM
thanks, that works for me :)