Windows 上是否有用于 SWT 的新行命令?如果没有,我在这里做错了什么?
这是代码
public static void main (String [] args) {
Display display = new Display();
Shell shell = new TabsTest().createShell(display);
shell.setSize(350,500);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
}
private Shell createShell(final Display display) {
final Shell shell = new Shell(display);
shell.setText("Betting Tracker");
//Creating grid layout, used to organize the shell
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 20;
shell.setLayout(gridLayout);
//Grid1
GridData gridData = new GridData(GridData.FILL, GridData.CENTER, true, false);
gridData.horizontalSpan = 20;
new Label(shell, SWT.NONE).setText("Bet Type:");
betType = new Combo(shell, SWT.SINGLE | SWT.BORDER);
betType.setItems(new String[] {" ", "NFL", "NBA", "CFB"});
betType.setLayoutData(gridData);
//Grid2
GridData gridData2 = new GridData(GridData.BEGINNING, GridData.CENTER, true, false);
gridData2.widthHint = 20;
gridData2.horizontalSpan = 5;
new Label(shell, SWT.NONE).setText("Bets Played:");
numBets = new Text(shell, SWT.NONE);
numBets.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
numBets.setLayoutData(gridData2);
new Label(shell, SWT.NONE).setText(" Won: ");
betsWon = new Text(shell, SWT.NONE);
betsWon.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
betsWon.setLayoutData(gridData2);
new Label(shell, SWT.NONE).setText(" Lost: ");
betsWon = new Text(shell, SWT.FILL);
betsWon.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, true));
betsWon.setLayoutData(gridData2);
//Grid3
GridData gridData3 = new GridData(GridData.CENTER, GridData.CENTER, true, false);
gridData3.horizontalSpan = 20;
new Label(shell, SWT.NONE).setText("Todays Lines");
lines = new List(shell, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL);
lines.setItems(new String[] { "OKC(+2.5) - MIA(-2.5)", "DAL(+8) - BOS(-8)" });
int listHeight = lines.getItemHeight() * 12;
trim = lines.computeTrim(0, 0, 0, listHeight);
gridData3.heightHint = trim.height;
lines.setLayoutData(gridData3);
return shell;
}
}
问题是我在 //Grid3 注释下创建了一个新标签。该标签贴在它上面的行上,而不是出现在新行上。我是 SWT 的新人,所以我知道这只是我缺乏知识。我会附上一张图片,以便您查看问题。
您可以看到标签“Todays Lines:”不在它自己的行上。
任何帮助将不胜感激!