Thursday 15 April 2010

swing - Class Structure and Location for MVC in Java -


I am writing a GUI for the Sudoku program. I am trying to use an MVC framework, the following post was the basis of the basis of my current code: My question is where do the action listeners go? I think they go to the controller, but is that one class or many? Currently I have a single class with a single action listener and if there is any other argument to deal with each swing component which can fire an event. This code smells for me though. Is there a preferred way to structure code? I hope some more buttons and components have to be added and I want to make sure that I am doing it down properly. I've read a lot of posts and web tutorials, but have received this answer so far.

Thanks

  The public class provides SudokuView JFrame {sudoku controller controller; // Sudoku Engine Sudoku Engine; Personal fixed final end yMar = 100; Private stable final int xMar = 25; Personal static final difference cellSize = 40; Private stable final interval grid space = 3; Private constant final integer secondspace = 9; Personal fixed final full width = 2 * xMar + 9 * cells + 2 * second space + 6 * gridspace + 10; Private stable final intensity height = 650; Public pocket [] [] gridbutton; Public sudoku () {controller = new sudoku controller (); // sudokuEngine = new Sudoku engine (); Gridbots = new pocket [9] [9]; SetTitle ("Sudoku Ninja 0.1"); SetSize (width, height); SetDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); SetLayout (zero); SetBackground (Color.GRAY); SetResizable (wrong); DrawBlankGrid (); SetVisible (true); } Public Zero SetSudoku Implementation (SudokuInine Interface Listener) {Controller. Sets Listener (Listener); } Public Final Zero DrawBlankGrid () {int y = yMar; For (int r = 0; r <9; r ++) {int x = xMar; For (int c = 0; c    

I got was very helpful. controller view and add-Listnr method Basically the internal classes of issues. In this way better organization

No comments:

Post a Comment