gpt4 book ai didi

java - 了解 java 或 GWT 中的组合

转载 作者:行者123 更新时间:2023-12-01 15:25:22 25 4
gpt4 key购买 nike

我在理解复合 Material 时遇到问题。

在Frame类中,当加载vp时,我有verticalPanel(vp),getAction和get Button在vp上可见

当单击按钮时,会执行 getTree,并且会在存在自定义树的地方初始化 treeC 类。和树项。

我想在 TreeC 类中使用操作对象

如何做。

请帮忙。

public class Frame{
public frame () {
initWidget(getFramePanel());
}
Private VerticalalPanel getFramePanel() {
if (vp== null) {
vp= new VerticalalPanel();
vp.setSize("1442px", "750px");
vp.add(getAction());// **are composites**
vp.add(getButton) // **are composite**

}
return vp;

private Action getAction() {
if (action == null) {
action = new Action(); // In action class there are 7 buttons and 2 methods //setDisplayRepository(), and setDisplayFolder()
action.setDisplayRepository();
}
return action;
}
}
private Button getButton() {
if (btn == null) {
btn = new Button("Click");
btnProperties.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
hp.add(getTree());
}
});
btn.setSize("37px", "36px");

}
return btnProperties;
}

private TreeCmis getTreeC() {
if (treeC == null) {
treeC = new TreeC();
treeC.setWidth("360px");
}
return treeCmis;
}
}
<小时/>
public class TreeC extends Composite{
private Tree repo;
//constructor
public TreeC {

createTree()
}
Void createTree(){
/* here i need to to use the object action declared in frame class
For using action.setDisplayfolder*/
}
}

最佳答案

最简单的方法是:

public class TreeC extends Composite{
private Tree repo;
private Action action;
//constructor
public TreeC(Action action) {
this.action = action;
createTree()
}
void createTree(){
/* here i need to to use the object action declared in frame class
For using action.setDisplayfolder*/
}
}

创建实例时treeC = new TreeC(action);

关于java - 了解 java 或 GWT 中的组合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10242618/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com