CrazyEngineers
  • Doubt regarding checking the game of sudoku (core java)

    Deepika Bansal

    Deepika Bansal

    @deepika-jf1ysv
    Updated: Oct 22, 2024
    Views: 926
    Hello everyone. I am working on a game of sudoku in core java. Till now I've been able to successfully generate a solution ( consisting of all filled boxes) and a game ( consisting of filled and empty boxes) from the generated solution. Now comes the turn of verifying the numbers (0-9) as inputted by the player against the initially known solution. I am not able to judge the correct event for this purpose. Please help me out. At the front end, I've used one panel ( container panel). On it are placed 9 other panels (blocks) each of which holds 9 text fields. One way is that I use key typed event on individual text fields. This makes a total of 81 events which is not a good option (I hope you too agree with me). Hence, I want an event that can be applied on a panel, either container or block, to get the number entered from the user end and appropriatly handle it. Please suggest me and let me know if I've missed out anything necessary.
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Deepika Bansal

    MemberMar 7, 2013

    PS- I've written this thread from my cell phone and was not able to create proper paragraphs. This was the best that I can write. Can't figure out why so.😒
    Are you sure? This action cannot be undone.
    Cancel
  • simplycoder

    MemberMar 7, 2013

    Hi Deepika,

    First question to you, are you coding to generate a sudoku or solve a sudoku?
    Generation is complicated as compared to Solving.
    A legal sudoku will have a only one solution.

    You do not have to write 81 listeners in any case,and I donot understand the purpose of 9 panels.

    You could have used just one single panel and using that you could have drawn a sudoku-grid in such way that each cell in grid would correspond to each memory location in the storage array(where you perform logical operations like checking for legal move,if a solution is correct...).

    A workaround for this is, you can provide user a cyclic rotating input.
    First the user would select the cell and then on repeating mouse click he can choose the characters from 0 to 9 and EMPTY.
    Are you sure? This action cannot be undone.
    Cancel
  • Deepika Bansal

    MemberMar 20, 2013

    #-Link-Snipped-#: Thanks for your sincere reply.
    Actually its a netbeans project which generates a sudoku game and lets the user end ie the player to solve it.

    Yes, I could have used one single panel instead of 9. I thought that will be more gui friendly to the user/player.

    My actual question is- I want to get the key typed by the user when s/he enters the value in one of the 81 text fields so that I can check for a legal move and do various other gui functions when it receives the focus. But I am not able to figure out the correct event. I've used the key typed, key pressed and key released event one the panel, and saw no effect.
    Hope now you've got my problem.
    Are you sure? This action cannot be undone.
    Cancel
  • Deepika Bansal

    MemberMar 22, 2013

    I've searched a bit on net for it and found that 'key binding' can probably help me. Is anybody aware of it?
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register