1

FlexTableでを使いたいDialogBox。のサイズは のサイズとDialogBox一致する必要がありFlexTableます。残念ながら、DialogBoxは小さいため、FlexTableはカットされており、一部しか表示されていません。が収まるDialogBoxように自動的にサイズを変更する方法はありますか? FlexTable(表示されている間は変更されないことに注意してください。そのFlexTableため、画面に表示された後の自動サイズ変更は必要ありません...)

誰かがすでにこれを達成しましたか?

4

2 に答える 2

2

何がいけなかったのか、今になって分かった気がします。そのような状況でも役立つかもしれないブライアンの素晴らしい答えに加えて(私の場合、自動サイジングとブライアンのアプローチの間に変更はありません)。アニメーションを使用する場合DialogBox、GWT の a の幅が 400 px に制限されていることがわかりました。回線変更時

setAnimationEnabled(true);

setAnimationEnabled(false);

DialogBox のサイズ変更は問題なく機能します。多分これは誰かのために役立つ...

于 2013-08-29T10:31:54.973 に答える
1

私のアプリケーションではDialogBox、テーブルのサイズを正確に判断できるようにモーダルがいつ画面に表示されるかを知る必要があるため、処理がはるかに簡単になるサブクラスを作成しました。

public class Modal extends DialogBox
{
  private VerticalPanel myContentPanel;
  private FlexTable myTable;

  public Modal( )
  {
    ...

    // Construct the modal and call `setWidget()` with something like a `VerticalPanel`
    super.setWidget( this.myContentPanel );
  }

  @Override
  public void onAttach( )
  {
    // This is called when the modal attaches to the DOM:
    super.onAttach( );

    // Heights still aren't quite valid, we need to defer the call one more frame.

    // Make ourselves invisible while we defer the call so we don't flicker:
    super.setVisible( false );

    // Defer until the next frame:
    Scheduler.get( ).scheduleDeferred( new ScheduledCommand( )
    {
      @Override
      public void execute( )
      {
        // Height on the table is now valid:
        int width  = myTable.getOffsetWidth( );
        int height = myTable.getOffsetHeight( );

        // Update the heights:
        Modal.this.myContentPanel.setSize( width + "px", height + "px" );
        Modal.this.setSize( width + "px", height + "px" );

        // Center and show ourselves:
        Modal.this.center( );
        Modal.this.setVisible( true );
      }
    });
  }
}

私の経験では、一貫性のある有効な結果を得るには、ウィジェットが DOM にアタッチされた後に getOffsetHeightandの呼び出しを延期する必要があることがわかりました。getOffsetWidth

于 2013-08-29T03:57:20.530 に答える