1

GWT には LazyPanel がありますか。表示されません。教えてください。lazyPanel がある場合は、バージョンを教えてください。

4

2 に答える 2

2

Google検索の原則についてはrustyshelfに同意しますが、StackOverflow自体も参照であるため、より詳細な回答を次に示します。

デフォルトでは、LazyPanelは表示されません。LazyPanelでsetVisible(true)が呼び出された場合にのみ、基になるウィジェットが作成されます。

このクラスは、子パネルに比較的重いコンテンツが含まれている場合、主にStackPanel、DisclosurePanel、およびTabPanelと組み合わせて使用​​する必要があります。LazyPanel
を 使用してこれらのコンテンツの作成をラップすると、ユーザーエクスペリエンスを大幅に向上させることができます。


LazyPanelの使用は簡単です。レイジーパネルにレイジーロードするウィジェットを追加し、レイジーパネルでsetVisible(true)を呼び出して、ウィジェットをオンデマンドで実際にロードするだけです。LazyPanelは、主にTabPanelやStackPanelなどのウィジェットでの使用を目的としており、すべての場合に理想的であるとは限りません。

于 2008-12-20T11:42:28.873 に答える
0

これが「リリース候補」GWT 1.6.2 の LazyPanel.java です。はい、単純で、上記の回答の確認です。

/*
 * Copyright 2008 Google Inc.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package com.google.gwt.user.client.ui;

/**
 * Convenience class to help lazy loading. The bulk of a LazyPanel is not
 * instantiated until {@link #setVisible}(true) or {@link #ensureWidget} is
 * called.
 * <p>
 * <h3>Example</h3> {@example com.google.gwt.examples.LazyPanelExample}
 */
public abstract class LazyPanel extends SimplePanel {

  public LazyPanel() {
  }

  /**
   * Create the widget contained within the {@link LazyPanel}.
   * 
   * @return the lazy widget
   */
  protected abstract Widget createWidget();

  /**
   * Ensures that the widget has been created by calling {@link #createWidget}
   * if {@link #getWidget} returns <code>null</code>. Typically it is not
   * necessary to call this directly, as it is called as a side effect of a
   * <code>setVisible(true)</code> call.
   */
  public void ensureWidget() {
    Widget widget = getWidget();
    if (widget == null) {
      widget = createWidget();
      setWidget(widget);
    }
  }

  @Override
  /*
   * Sets whether this object is visible. If <code>visible</code> is
   * <code>true</code>, creates the sole child widget if necessary by calling
   * {@link #ensureWidget}.
   * 
   * @param visible <code>true</code> to show the object, <code>false</code> to
   * hide it
   */
  public void setVisible(boolean visible) {
    if (visible) {
      ensureWidget();
    }
    super.setVisible(visible);
  }
}
于 2009-03-26T02:05:04.307 に答える