Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在GWT中调整对话框的大小,以使FlexTable适合?_Gwt_Dialog_Flextable - Fatal编程技术网

如何在GWT中调整对话框的大小,以使FlexTable适合?

如何在GWT中调整对话框的大小,以使FlexTable适合?,gwt,dialog,flextable,Gwt,Dialog,Flextable,我想在对话框中使用FlexTable。 对话框的大小应与FlexTable的大小相匹配。 不幸的是,对话框较小,因此FlexTable被剪切,只有部分可见。 是否有一种方法可以自动调整对话框的大小,以使FlexTable适合? (请注意,FlexTable在显示时不会改变,因此在屏幕上显示后无需自动调整大小…) 有人已经完成了吗?在我的应用程序中,我创建了一个对话框子类,它使事情更容易处理,因为您必须知道模式何时出现在屏幕上,以便您可以准确地确定表的大小 public class Modal e

我想在
对话框中使用
FlexTable
对话框
的大小应与
FlexTable
的大小相匹配。 不幸的是,
对话框
较小,因此
FlexTable
被剪切,只有部分可见。 是否有一种方法可以自动调整
对话框的大小
,以使
FlexTable
适合? (请注意,
FlexTable
在显示时不会改变,因此在屏幕上显示后无需自动调整大小…)


有人已经完成了吗?

在我的应用程序中,我创建了一个
对话框
子类,它使事情更容易处理,因为您必须知道模式何时出现在屏幕上,以便您可以准确地确定表的大小

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之后,您需要将
getOffsetSight
getOffsetWidth
调用延迟一次,以获得一致、有效的结果

我想我现在发现了问题所在。 除了Bryan的回答之外,这在这种情况下可能也会有所帮助(尽管在我的工作中,自动调整尺寸和Bryan的方法之间没有变化)。 我发现在使用动画时,GWT中
对话框的宽度限制为400 px。
换线时

setAnimationEnabled(true);

对话框的大小非常好。
也许这对某人有帮助…

使用您的方法时没有任何变化。奇怪的是,不管怎样,这个高度还是不错的。只是宽度不正确。实际上,宽度似乎没有超过400px。当桌子变小时,即使盒子的宽度也是正确的。我只在拥有比400px更宽的表时才看到这个问题。我必须更新我的
对话框
子类。我实际上没有使用GWT动画,所以我不知道。谢谢
setAnimationEnabled(false);