如图,运行时的界面和的design的界面不一样,我想要的界面是设计显示的界面,不知道哪位有空帮帮忙?
界面的代码如下:
import org.eclipse.swt.SWT;public class CallInterface {
private Composite composite;
protected Shell shell;
protected Image image;
protected Image image1; /**
 * Launch the application
 * 
 * @param args
 */
public static void main(String[] args) {
try {
CallInterface window = new CallInterface();
window.open();
} catch (Exception e) {
e.printStackTrace();
}
} /**
 * Open the window
 */
public void open() {
final Display display = Display.getDefault();
image = new Image(display, "src/image/logo.gif");
image1 = new Image(display, "src/image/call.jpg");
createContents();
shell.open();
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
} /**
 * Create contents of the window
 */
protected void createContents() {
shell = new Shell();
shell.setSize(300, 600);
shell.setText("柜员呼叫端,窗口号:001");
shell.setLayout(new GridLayout(7, true));
composite = new Composite(shell, SWT.BORDER);
GridData gridComposite = new GridData(GridData.FILL_BOTH);
gridComposite.horizontalSpan = 7;
composite.setLayoutData(gridComposite);
{ composite.setLayout(new GridLayout(5, false));
// 员工图片
Button buttonImage = new Button(composite, SWT.NONE);
GridData buttonIGD = new GridData();
buttonIGD.horizontalSpan = 1;
buttonIGD.verticalSpan = 2;
buttonImage.setLayoutData(buttonIGD);
// buttonImage.setSize(40, 50);
buttonImage.setImage(image);
Composite c1 = new Composite(composite, SWT.NONE);
GridData c1GridData = new GridData(GridData.END);
c1GridData.horizontalSpan = 4;
c1.setLayoutData(c1GridData);
{
c1.setLayout(new GridLayout(5, false));
// 工号
final Label userNo = new Label(c1, SWT.NONE);
GridData noGridData = new GridData();
noGridData.horizontalSpan = 2;
userNo.setLayoutData(noGridData);
userNo.setText("工号:"); GridData textGridData = new GridData();
textGridData.horizontalSpan = 2;
final Text text = new Text(c1, SWT.READ_ONLY | SWT.NONE
| SWT.WRAP); text.setText("0011");
text.setLayoutData(textGridData);
// 员工名字
final Label userNameLabel = new Label(c1, SWT.NONE);
GridData nameGridData = new GridData();
nameGridData.horizontalSpan = 2;
userNameLabel.setLayoutData(nameGridData);
userNameLabel.setText("名字:"); final Text nameText = new Text(c1, SWT.READ_ONLY | SWT.NONE
| SWT.WRAP);
nameText.setText("MICROSOFT");
nameText.setLayoutData(textGridData); }
// 定义labSeparator分隔符标签,并对其进行布局
final Label labSeparator = new Label(composite, SWT.SEPARATOR
| SWT.HORIZONTAL);
GridData gridSeparator = new GridData(GridData.FILL_HORIZONTAL);
gridSeparator.horizontalSpan = 5;
gridSeparator.verticalSpan = 2;
labSeparator.setLayoutData(gridSeparator); Composite c2 = new Composite(composite, SWT.BORDER);
GridData c2GridData = new GridData(GridData.FILL_BOTH);
c2GridData.horizontalSpan = 5;
c2GridData.verticalSpan = 10;
c2.setLayoutData(c2GridData);
{
c2.setLayout(new GridLayout(5, false));
TabFolder tabFolder = new TabFolder(c2, SWT.NONE);
GridData tabGridData = new GridData(GridData.FILL_BOTH);
tabGridData.horizontalSpan = 5;
tabFolder.setLayoutData(tabGridData);
// 第一个选项卡
{
GridData itemGridData = new GridData();
itemGridData.horizontalSpan = 5;
TabItem item = new TabItem(tabFolder, SWT.NONE);
item.setText("主要功能");
{
Composite itemComposite = new Composite(tabFolder,
SWT.NONE);
itemComposite.setLayout(new GridLayout(4, false));
item.setControl(itemComposite);
// 呼叫图片
Button callImage = new Button(itemComposite, SWT.NONE);
GridData callIGD = new GridData();
callIGD.horizontalSpan = 2;
callIGD.verticalSpan = 2;
callImage.setLayoutData(callIGD);
// buttonImage.setSize(40, 50);
// callImage.setImage(image1); // 说明
    Text nameText = new Text(itemComposite, SWT.READ_ONLY
| SWT.BORDER | SWT.WRAP);
GridData tg = new GridData();
tg.horizontalSpan = 2;
tg.verticalSpan=2;
nameText.setText("呼叫");
nameText.setLayoutData(tg);


Button recallButton = new Button(itemComposite,SWT.NONE);
GridData recallIGD = new GridData();
callIGD.horizontalSpan = 4;
callIGD.verticalSpan = 2;
recallButton.setText("重呼");
recallButton.setLayoutData(recallIGD);

Button selectButton = new Button(itemComposite,SWT.NONE);
GridData selectIGD = new GridData();
selectIGD.horizontalSpan = 4;
selectIGD.verticalSpan = 2;
selectButton.setText("选呼");
selectButton.setLayoutData(selectIGD); }
}
// 第二个选项卡
{
GridData itemGridData = new GridData();
itemGridData.horizontalSpan = 5;
TabItem item = new TabItem(tabFolder, SWT.NONE);
item.setText("用户参数");
}
} }
//
}}
PS:CSDN好像传不了本地图片,我说明一下,就是运行的时候“呼叫“这两个字应该是在第一行的,重呼按钮是独占一行的。这样也和design中的一样。
但是运行的时候”呼叫“这两个字排到了第二行,和重呼按钮排在了一起。这是怎么回事?