Results 1 to 2 of 2
Thread: Tic-Tac-Toe in SWT
- 04-20-2010, 12:36 AM #1
Member
- Join Date
- Apr 2010
- Posts
- 1
- Rep Power
- 0
Tic-Tac-Toe in SWT
How do I create the buttons with an array? I am going to do a Tic-Tac-Toe game in SWT. I guess this way is wrong?:
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.*;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.*;
public class Application {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Tic-Tac-Toe");
// creates the gridlayout
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 3;
gridLayout.marginWidth = 50;
gridLayout.marginHeight = 50;
gridLayout.horizontalSpacing = 10;
gridLayout.verticalSpacing = 10;
gridLayout.makeColumnsEqualWidth = true;
shell.setLayout(gridLayout);
// creates the buttons
Button[][] button = new Button[3][3];
shell.pack();
shell.open();
shell.setSize(700, 700);
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
- 04-20-2010, 10:51 PM #2


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks