自分で作ったり提供したりするものは、まず自分自身で使ってみろろということです。自分じゃ使わないものなら人はいくらでも無責任にも無思考にもなれる。そういう投げやりな「サービス」やら「プロダクツ」なんて、だれだってイヤだ。自分が作り手と同時に利用者の立場になれば、ちゃんと使えるレベルのものを提供しようとします。

2010年4月13日火曜日

GWT Tips

①ウィジェット削除
RootPanel.get().remove(w); // wはウィジェット
或は
DOM.removeChild(RootPanel.getBodyElement(), w.getElement());

使用例:
ログインした後にメイン画面に遷移する
RootPanel.get().clear(); //或は RootPanel.get().remove(loginView);
RootPanel.get().add(mainView);

②DialogBoxは画面中央に表示
dialogBox.center();
或は
final DialogBox d = new DialogBox();
d.setText("DialogBox");
DeferredCommand.add(new Command(){
    public void execute()
    {
        int x = (Window.getClientWidth()-d.getOffsetWidth())/2;
        int y = (Window.getClientHeight()-d.getOffsetHeight())/2;
        d.setPopupPosition(x, y);
    }
});
d.show();
このサンプルもDeferredCommandクラスのいい使用例です。

③改行しないLabelウィジェット
Label label = new Label("ラベル内容");
//css : white-space: nowrap;
DOM.setStyleAttribute(label.getElement(), "white-space", "nowrap");

0 件のコメント:

コメントを投稿

ホームページ