I'm building a sudoku game. Eventually I want the numbers to randomize in the beginning of each game. For now I simply want a preset board. This is the code I have been playing with to make the gui:
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package newestlatestgui; import java.awt.*; import java.awt.event.*; public class NewestLatestGui extends Frame implements WindowListener { public GridLayout() { super("GridLayout"); addWindowListener(this); setLayout(new GridLayout(0, 3, 5, 10)); for (int b=1; b <= 9; b++) { add(new Button("Button " + b)); } pack(); setVisible(true); } public static void main(String args[]) { GridLayoutTest glt = new GridLayoutTest(); } }
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package newestlatestgui; import java.awt.*; import java.awt.event.*; public class SimpleFrameTest { public static void main(String argsp[]) { Frame frame = new Frame("Simple Frame Test"); frame.setSize(900, 900); frame.setVisible(true); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { // Dispose the window after the close button is clicked. frame.dispose(); } }); } }
Any suggestions on how to program this?