Situation: I'm working with Wicket's IndicatingAjaxButton
. I have the button set up on a page with black background. When the user pushes the button, the button's activity indicator goes off and spins until the system is ready to move on.
Problem: Because of the black background, the indicator looks bad. Since part of the indicator is animated in black, some of the details are lost using the indicator on a black background.
Question: Is it possible in Wicket to change the color of the IndicatingX
[Button, Link, etc.], or do I have to design my page in a new way?
This is not possible. Well, not programmatically.
Wicket's activity indicator/throbber/spinner is actually nothing more than an animated GIF. It's located at
[your version of Wicket here]\wicket-src\wicket\src\main\java\org\apache\wicket\ajax\indicator.gif
and referenced in AbstractDefaultAjaxBehavior
.
To change the colors, you could create your own animated GIF of the same size and overwrite the one that's included in the default distribution.
EDIT:
Okay, after writing that I thought "there must be free icons available" and came up with this through Google Image Search:
I think it's free and unrestricted to use, but I didn't check too carefully. You should check for yourself if you're using it for anything more than a personal toy/sample app.
So piggybacking off what Lord Torgamus provided, you could add a class like this:
abstract class OnBlackIndicatingAjaxButton extends AjaxButton implements
IAjaxIndicatorAware {
private final AjaxIndicatorAppender indicatorAppender = new
AjaxIndicatorAppender() {
@Override
protected CharSequence getIndicatorUrl() {
return "http://blogs.msdn.com/blogfiles/gduthie/WindowsLiveWriter/Needananimatedloadingicon_B811/ajax-loader_2.gif";
}
};
public OnBlackIndicatingAjaxButton(String id) {
super(id);
add (indicatorAppender);
}
public OnBlackIndicatingAjaxButton(String id, Form<?> form)
{
super(id, form);
add (indicatorAppender);
}
/**
* @see IAjaxIndicatorAware#getAjaxIndicatorMarkupId()
* @return the markup id of the ajax indicator
*
*/
public String getAjaxIndicatorMarkupId()
{
return indicatorAppender.getMarkupId();
}
}
and use that for any of your pages.
来源:https://stackoverflow.com/questions/5665729/is-it-possible-to-change-the-color-of-wickets-activity-indicator