gpt4 book ai didi

java - SWT - 如何在向导中创建两个复合 Material

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

我的类(class)中有几个用于不同目的的复合 Material ,并且我已将控件放入其中。我的问题是我需要在页面的右侧有一个复合 Material ,该复合 Material 由边框分隔开,右侧复合 Material 需要呈矩形形状,垂直填充向导,其中我只显示一些超链接。任何帮助将不胜感激。而且绿色覆盖了我的标签文本,并且文本根本不显示,我该如何解决这个问题?

我无法发布任何图片,因为我只有 6 个声誉,而且我对 StackOverflow 还比较陌生。如果我能获得 10 个声望,那么我会非常乐意发布屏幕截图。

这是我的代码:

public void createControl(Composite parent) {
Display device = Display.getCurrent ();
Composite top = new Composite(parent, SWT.NONE);
top.setLayout(new GridLayout(1,true));

Composite topCompo = new Composite(top, SWT.BORDER);
topCompo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Label label = new Label(topCompo, SWT.BORDER);
label.setText("Before you continue the person must have a first name and a last name");
RGB rgb = new RGB(183,240,194);
Color color = new Color(device,rgb);
topCompo.setBackground(color);


Composite left = new Composite(top, SWT.NONE);
left.setLayout(new GridLayout(2,true));

Label label1 = new Label(left, SWT.NONE);
label1.setText("First Name");
text1 = new Text(left, SWT.BORDER);
text1.setText("");

Label label2 = new Label(left, SWT.NONE);
label2.setText("Last Name");
text2 = new Text(left, SWT.BORDER);
text2.setText("");

Label label3 = new Label(left, SWT.FILL);
label3.setText("Positions");
Combo combo = new Combo (left, SWT.READ_ONLY);
combo.setItems (new String [] {"White Position","No Position"});
combo.select(0);

Composite leftRadio = new Composite(top, SWT.NONE);
leftRadio.setLayout(new GridLayout(3,true));

Label label4 = new Label(leftRadio, SWT.FILL);
label4.setText("Physician Indicator:");

Button b = new Button(leftRadio, SWT.RADIO);
b.setText("Yes");
b.setSelection(true);
new Button(leftRadio, SWT.RADIO).setText("No");


Label addrLabel = new Label(leftRadio, SWT.BOLD);
addrLabel.setFont( new Font(device," ", 9, SWT.BOLD));
addrLabel.setText("Addresses");

Composite right = new Composite(parent,SWT.BORDER|SWT.RIGHT);
right.setLayout(new GridLayout(1,false));
new Button(right, SWT.RADIO).setText("No");



Composite tableParent = new Composite(top, SWT.NONE);
tableParent.setLayout(new GridLayout(1,true));

TableViewer viewer = new TableViewer(tableParent, SWT.MULTI | SWT.H_SCROLL
| SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
final Table table = viewer.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
viewer.setContentProvider(ArrayContentProvider.getInstance());

TableViewerColumn colType = new TableViewerColumn(viewer, SWT.NONE);
colType.getColumn().setWidth(100);
colType.getColumn().setText("Type");

TableViewerColumn colStreet = new TableViewerColumn(viewer, SWT.NONE);
colStreet.getColumn().setWidth(200);
colStreet.getColumn().setText("Street");

TableViewerColumn colCity = new TableViewerColumn(viewer, SWT.NONE);
colCity.getColumn().setWidth(150);
colCity.getColumn().setText("City");

TableViewerColumn colState = new TableViewerColumn(viewer, SWT.NONE);
colState.getColumn().setWidth(130);
colState.getColumn().setText("State");

TableViewerColumn colZIPCode = new TableViewerColumn(viewer, SWT.NONE);
colZIPCode.getColumn().setWidth(130);
colZIPCode.getColumn().setText("Zip Code");

Composite buttons = new Composite(top, SWT.NONE);
buttons.setLayout(new GridLayout(2,true));
new Button(buttons, SWT.NONE).setText("Add");
Button b2 = new Button(buttons, SWT.NONE);
b2.setText("Remove");
b2.setEnabled(false);

text2.addKeyListener(new KeyListener() {
@Override
public void keyPressed(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
if (!text1.getText().isEmpty()) {
setPageComplete(true);

}
}

});
setControl(top);
setPageComplete(false);
color.dispose();
}

我需要在右侧放置一个单独的合成图,它只是一个矩形形状的小合成图,并且它应该垂直填充页面。

最佳答案

我找到了解决方案。我使用了一个具有三列的父复合 Material 及其 3 个子复合 Material ,这些子复合 Material 将在带有分隔符的向导中分为 3 列,它工作得很好,而且我似乎也掌握了 GridLayout 和 GridData 的窍门。

关于java - SWT - 如何在向导中创建两个复合 Material ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24030498/

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