繁体   English   中英

GWT使用小部件和事件

[英]GWT work with widgets and events

我米,GWT 2.4的新应用程序的工作。 我做了一个docklayoutpanel,并在它的西段插入了一个单元格列表。 我需要创建一个事件,每次用户单击页面西侧的单元格列表元素时,都会在docklayoutpanel的内容中加载特定的小部件。

有什么建议么?

谢谢

以下示例应为自我解释

// Create a cell to render each value.
TextCell textCell = new TextCell();

// Create a CellList that uses the cell.
CellList<String> cellList = new CellList<String>(textCell);
cellList.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);

// Add a selection model to handle user selection.
final SingleSelectionModel<String> selectionModel = new SingleSelectionModel<String>();
cellList.setSelectionModel(selectionModel);
selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
  public void onSelectionChange(SelectionChangeEvent event) {
    String selected = selectionModel.getSelectedObject();
    if (selected != null) {
      Window.alert("You selected: " + selected);
    }
  }
});

代替Window.alert("You selected: " + selected); 您将需要更改面板东部显示的小部件。

这可以通过多种方式完成,其中一种方式是通过将Panel声明为类的字段(而不是类的构造函数中的局部变量)或作为最终的局部变量,使Dockpanel暴露于Selection Change事件。在构造函数中。

另一种方法是通过事件处理来实现。 在MVP的设计模式的eventBus方法是做所有thesee有道这里了解更多信息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM