Cannot find symbol, char cannot be dereferenced

“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” (Mosher's Law of Software Engineering)
“If debugging is the process of removing bugs, then programming must be the process of putting them in.” (Edsger Dijkstra)

This is solution for Error 1.
isDigit() is a static method of Character wrapper class. A char is a primitive and not an object on which you can invoke methods.

I am not sure what you are trying to accomplish using Commit().

Thanks
Abhishek

Habeeb Shaikh

Ranch Hand

Posts: 48

posted 6 years ago

1

Hi,

In the above code what you really want to do ?
You have to commit data which is coming through source. first thing that you have to check it is which type of data.either string or int. then you have to you JDBC interface which will help to insert, save and commit data into the database.

Abhi Kr wrote:I am not sure what you are trying to accomplish using Commit().

I've read John's other threads, and I know that yummy and stupid are instances of JFormattedTextField.

But John, have you checked the API? Where did you find that "Commit(boolean)" method? Because the only committing method JFormattedTextField has is commitEdit(). And you forgot to cast the result of e.getSource() to JFormattedTextField before calling the method.

I'm supposed to do something like JFormattedTextField.REVERT...but how is it supposed to know? Something like:

or something. Please help me with the syntax.
Thanks,
cc11rocks

“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” (Mosher's Law of Software Engineering)
“If debugging is the process of removing bugs, then programming must be the process of putting them in.” (Edsger Dijkstra)

Matthew Brown

Bartender

Posts: 4568

9

posted 6 years ago

1

Firstly, as Rob says, you need to cast the result of e.getSource() to a JFormattedTextField before you can use methods that belong to that class:

Secondly, check out the Javadocs for JFormattedTextField. REVERT is a constant, and the documentation says "see Also: setFocusLostBehavior(int)". So it looks like that's relevant.

(The docs also have an example on how to do input validation, which might be helpful)

Still not getting it. I did look at the JavaDocs and tried to mimic it.
There are no good example online that are different from my new code:

Error:

“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” (Mosher's Law of Software Engineering)
“If debugging is the process of removing bugs, then programming must be the process of putting them in.” (Edsger Dijkstra)

Matthew Brown

Bartender

Posts: 4568

9

posted 6 years ago

1

See my last message - you'll have to cast the result of e.getSource().

Matthew Brown wrote:See my last message - you'll have to cast the result of e.getSource().

Where do I put this?

And what does it mean?

“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” (Mosher's Law of Software Engineering)
“If debugging is the process of removing bugs, then programming must be the process of putting them in.” (Edsger Dijkstra)

I understand now. My code is compiling but not working right. It seems to not reverting. To test whether it was working, I added "System.out.println(question);". It is printing out true or false at the right time, but not actually doing anything else. The REVERT seems to not be working.

Please help,
cc11rocks

“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” (Mosher's Law of Software Engineering)
“If debugging is the process of removing bugs, then programming must be the process of putting them in.” (Edsger Dijkstra)