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(); } }