0
在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全新的,所以我知道這只是我缺乏的知識。我會添加一張照片,以便您看到問題。
你可以看到標籤「今天行:」是不是在它自己的路線。
任何幫助將非常感激!
很好的答案,謝謝你專門爲我的程序量身定做,這讓我非常有幫助,並且更清楚我做錯了什麼。謝謝你,祝聖誕快樂! – Hoser