Is it possible to change the color of Wicket's activity indicator?

混江龙づ霸主 提交于 2019-12-20 03:19:32

问题


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?


回答1:


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:

http://blogs.msdn.com/blogfiles/gduthie/WindowsLiveWriter/Needananimatedloadingicon_B811/ajax-loader_2.gif

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.




回答2:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!