java - Infinite Rotation Command (or button) in toolbar in Codename One -
i'd 'infinite' rotate on of commands (the refresh command) in codename one toolbar (until loading done, want stop rotation, image still has visible). can change icon start rotation? how can achieve result?
the rotating icon should not clickable when rotating, should not hard implement.
you can use toolbar api , little bit of hack. created methods below that:
private void showtitleprogress(toolbar t) { int pos = t.getcomponentcount() - 1; //if have command on left command //int pos = t.getcomponentcount(); //if don't have command on left command infiniteprogress ip = new infiniteprogress(); ip.setanimation(yourprogressimage); ip.setuiid("icon"); container contip = flowlayout.enclosecentermiddle(ip); component.setsamewidth(t.getcomponentat(pos), contip); component.setsameheight(t.getcomponentat(pos), contip); t.replaceandwait(t.getcomponentat(pos), contip, null); t.revalidate(); } private void hidetitleprogress(toolbar t, command cmd) { int pos = t.getcomponentcount() - 1; //if have command on left command //int pos = t.getcomponentcount(); //if don't have command on left command button cmdbutton = new button(cmd.geticon()); cmdbutton.setuiid("titlecommand"); cmdbutton.setcommand(cmd); t.replaceandwait(t.getcomponentat(pos), cmdbutton, null); t.getcomponentform().revalidate(); } use toolbar api , form this:
private command mycommand = new command(""); form f = new form("test form"); toolbar t = new toolbar(); f.settoolbar(t); command = new command("back") { @override public void actionperformed(actionevent evt) { //do stuff } }; back.putclientproperty("uiid", "backcommand"); f.setbackcommand(back); t.addcommandtoleftbar(back); mycommand = new command(yourprogressimage) { @override public void actionperformed(actionevent evt) { //to show progress when actions being performed showtitleprogress(t); //when you're done, discard progress , restore command hidetitleprogress(t, mycommand); } } mycommand.putclientproperty("titlecommand", true); t.addcommandtorightbar(mycommand); f.show();
Comments
Post a Comment