• Post Reply Bookmark Topic Watch Topic
  • New Topic

Cannot find symbol, char cannot be dereferenced

 
john price
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

yummy = JFormattedTextField
stupid = JFormattedTextField
Commit is only for SQL supposedly? How do I make it work with java?
Errors:
 
Abhishek A Kumar
Greenhorn
Posts: 2
Eclipse IDE Java Ubuntu
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
char z324 = e.getKeyChar();
boolean question = Character.isDigit(z324);

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
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rob Spoor
Sheriff
Posts: 20821
68
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
john price
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Errors:

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
 
Matthew Brown
Bartender
Posts: 4568
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
john price
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
Matthew Brown
Bartender
Posts: 4568
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See my last message - you'll have to cast the result of e.getSource().
 
john price
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Rob Spoor
Sheriff
Posts: 20821
68
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Scroll down to "Casting Objects". Method calling has a higher precedence so another pair of parentheses is used to solve that.
 
john price
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!