如何加载复合材料的一部分并使其他部分保持静态? [英] How to load a part of composite keeping others static?

查看:72
本文介绍了如何加载复合材料的一部分并使其他部分保持静态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在SWT中有一个表单,其中基于一个父组合有五个不同的组合,每个组合都包含不同的小部件,例如单个文本框/组合框/文本和组合的组合等.

I have a form in SWT where I have five different composites based on one parent composite.Each of the composite contains different widgets like a single textbox / a combo box / a combination of text and combo etc.

现在的问题是,当我单击按钮时,我想更改我的第三个复合材料以携带一个使其他部件保持静态的不同小部件.现在我无法从头开始重新加载,因为我希望显示其他小部件的当前值我该如何仅获取该复合材料,进行处理并代替它创建一个新的小部件.

Now the problem is when I click on the button I want to change my third composite to carry a different widget keeping others static.Now I can't reload from the beginning as I want current values of the other widgets to be displayed.How can I fetch only that composite,dispose it and create a new widget in place of that.

创建和隐藏窗口小部件很难考虑,因为它在我们要重绘的位置是动态的.

Creating and hiding the widget is difficult to consider as it is dynamic to at what place we want to redraw.

这是代码段.

    formComposite=new Composite(parentComposite,SWT.BORDER_SOLID);
    formLayout=new GridLayout(5,false);
    fromComposite.setLayout(formLayout)
    item.create(formComposite)  //Here item is the widget (combo/textbox/combination text/combo)

     formComposite1=new Composite(parentComposite,SWT.BORDER_SOLID);
    formLayout1=new GridLayout(5,false);
    fromComposite1.setLayout(formLayout)
    item1.create(formComposite1))

  formComposite2=new Composite(parentComposite,SWT.BORDER_SOLID);
    formLayout2=new GridLayout(5,false);
    fromComposite2.setLayout(formLayout)
    item2.create(formComposite2))

 formComposite3=new Composite(parentComposite,SWT.BORDER_SOLID);
    formLayout3=new GridLayout(5,false);
    fromComposite3.setLayout(formLayout)
    item3.create(formComposite3))

 formComposite4=new Composite(parentComposite,SWT.BORDER_SOLID);
    formLayout4=new GridLayout(5,false);
    fromComposite4.setLayout(formLayout)
    item4.create(formComposite4))

现在我如何用要创建的其他项目替换item3,以使其他人保持原样?

Now how can I replace item3 with a different item to be created keeping others static in their place?

推荐答案

假设每个Composite只有一个孩子,则只需处置现有控件并添加新控件,然后重做布局即可.

Assuming you only have one child for each Composite you can just dispose of the existing control and add the new one and then redo the layout.

item.dispose();

item = new Combo(fromComposite, ... style);

formComposite.layout(true);

您可能还必须在parentComposite上致电layout.

You may also have to call layout on the parentComposite.

这篇关于如何加载复合材料的一部分并使其他部分保持静态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆