my dog learned polymorphism*
The moose likes Swing / AWT / SWT and the fly likes JTable problem / Sudoku problem - Problem with if Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable problem / Sudoku problem - Problem with if" Watch "JTable problem / Sudoku problem - Problem with if" New topic
Author

JTable problem / Sudoku problem - Problem with if

Joe Paneus
Greenhorn

Joined: Apr 30, 2012
Posts: 1
Hi, I'm Joe and I have a problem with JTable.



Basically the problem is like this. I have 2 JTables, 1 with all the values, correct values. The other one has got some of the values (it represents a sudoku), and you have to fill it up inside the application. When I fill it up with the same numbers as these ones here (in tabela) it checks if the values in table (the one i'm filling up) are the same as the values in tabela (the one that is already finished). If everything is correct, the variable temp stays true, and it should say: "Good job! You're finished!".

Although all the numbers are the same, and the sequence is also the same, it doesn't say that I'm finished, that I've completed it, but it says "Incorrect". It always says it's wrong, whatever numbers (correct or not) i put in.
I've done a check with the numbers already put in the table (the fixed numbers, the ones you see here in the code), and the mistake doesn't get made. In other words, he recognizes that the value in row 2, column 0 in the JTable table is the same value as the one in row 2, column 0 in the tabela.
But when I write a number in the table manually (after I start the app), for instance i put the number 2 onto row 0, column 0 (the first place in the table), it says it's not the correct value as the one in tabela.
Basically it says that 2 isn't equal to 2 !?

I'm using eclipse-SDK-3.7.1

Any help is appreciated.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
table.getValueAt(i, j)!=tabela.getValueAt(i, j)

getValueAt() returns an object, so you may need to use .equals() for comparison
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTable problem / Sudoku problem - Problem with if