Doubt regarding checking the game of sudoku (core java)

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.

Replies

  • Deepika Bansal
    Deepika Bansal
    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.😒
  • simplycoder
    simplycoder
    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.
  • Deepika Bansal
    Deepika Bansal
    #-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.
  • Deepika Bansal
    Deepika Bansal
    I've searched a bit on net for it and found that 'key binding' can probably help me. Is anybody aware of it?

You are reading an archived discussion.

Related Posts

Me

My name is Okonji Chianu Moses. I am from Nigeria and I have a Bachelor degree in Chemical Engineering. For nw, i am unemployed and I am looking for a...
Can we retain a variable value in PHP after closing the application(with a new session every time),without saving it to any database or file?If yes,how?
Can we download Talking Tom app in Nokia-C1-01 handset? If yes, then how.
we know that magnetic flux travels from north pole to south pole.. wt happens if we place a super conductor(which doesn't allow magnetic flux to pass form it) in middle...
Data signals may now be transmitted over illuminating LEDs, if a consortium of universities led by Stathclyde get their way. WiFi routers may no longer be needed. https://machinedesign.com/article/le...@ttkprestige.com&YM_MID=1378101&sfvc4enews=42