Java 如何显示包含更新数据的SWT复合块

Java 如何显示包含更新数据的SWT复合块,java,user-interface,swt,composite,Java,User Interface,Swt,Composite,我有一个关于SWT复合块的问题。。我构建了一个Composite块,在这里我将读取我的数据,但问题是我现在在.xml文件中有两个相同的日期,我希望在打开GUI时更新组合以显示新数据 我如何制作复合块以一个接一个地绘制新数据 import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets

我有一个关于SWT复合块的问题。。我构建了一个
Composite
块,在这里我将读取我的数据,但问题是我现在在.xml文件中有两个相同的日期,我希望在打开GUI时更新组合以显示新数据

我如何制作
复合块
以一个接一个地绘制新数据

import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.GridData;
import org.eclipse.wb.swt.SWTResourceManager;

import testic.CurrentData;
import testic.NODE;
import testic.ReadWrite;

import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;

public class MNode extends Composite {
    private Text text;
    private Text text_1;
    private Text text_2;

    private static CurrentData currentData = null;
    static ReadWrite userinterface;

    /**
     * Create the composite.
     * @param parent
     * @param style
     */
    public MGWSIMNode(Composite parent, int style) {
        super(parent, style);
        setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
        setLayout(new FormLayout());

        currentData = new CurrentData();
        userinterface = new ReadWrite(currentData) ;
        userinterface.readXML();

        for(NODE Node:currentData.getNodes()){

            Composite composite = new Composite(this, SWT.BORDER);
            composite.setLayout(new GridLayout(7, false));
            FormData fd_composite = new FormData();
            fd_composite.top = new FormAttachment(0, 10);
            fd_composite.left = new FormAttachment(0, 10);
            fd_composite.bottom = new FormAttachment(0, 96);
            fd_composite.right = new FormAttachment(0, 1461);
            composite.setLayoutData(fd_composite);

            Label lblMgw = new Label(composite, SWT.NONE);
            lblMgw.setText("MGWSIM");
            new Label(composite, SWT.NONE);
            new Label(composite, SWT.NONE);
            new Label(composite, SWT.NONE);
            new Label(composite, SWT.NONE);
            new Label(composite, SWT.NONE);

            Button btnNewButton_1 = new Button(composite, SWT.FLAT | SWT.CENTER);
            GridData gd_btnNewButton_1 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
            gd_btnNewButton_1.widthHint = 24;
            gd_btnNewButton_1.heightHint = 24;
            btnNewButton_1.setLayoutData(gd_btnNewButton_1);
            btnNewButton_1.setImage(SWTResourceManager.getImage("C:\\Users\\bebehind\\Pictures\\remove-button.png"));
            btnNewButton_1.setText("\r\n");
            btnNewButton_1.addSelectionListener(new SelectionAdapter() {
                public void widgetSelected(SelectionEvent e) {
                    dispose();
                }

            });

            Label lblHost = new Label(composite, SWT.NONE);
            GridData gd_lblHost = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
            gd_lblHost.widthHint = 36;
            lblHost.setLayoutData(gd_lblHost);
            lblHost.setText("Host:");

            text = new Text(composite, SWT.BORDER);
            GridData gd_text = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
            gd_text.widthHint = 375;
            text.setLayoutData(gd_text);
            text.setText(Node.getHost());

            Label lblType = new Label(composite, SWT.NONE);
            GridData gd_lblType = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
            gd_lblType.widthHint = 79;
            lblType.setLayoutData(gd_lblType);
            lblType.setText("Type:");

            text_1 = new Text(composite, SWT.BORDER);
            GridData gd_text_1 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
            gd_text_1.widthHint = 375;
            text_1.setLayoutData(gd_text_1);
            text_1.setText(Node.getType());


            Label lblIdentifier = new Label(composite, SWT.NONE);
            GridData gd_lblIdentifier = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
            gd_lblId.widthHint = 58;
            lblId.setLayoutData(gd_lblId);
            lblId.setText("Id:");

            text_2 = new Text(composite, SWT.BORDER);
            GridData gd_text_2 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
            gd_text_2.widthHint = 375;
            text_2.setLayoutData(gd_text_2);
            text_2.setText(Node.getId());
            Node.setId(text_2.getText());
            new Label(composite, SWT.NONE);

        }
    }

    @Override
    protected void checkSubclass() {
        // Disable the check that prevents subclassing of SWT components
    }
}

您最好使用
table
控件(或者
TableViewer
如果这是一个Eclipse插件)来创建一个表。谢谢,但这是否意味着我需要tp make table来代替composit block,然后在我创建table之后呢