• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Cannot find symbol, char cannot be dereferenced

 
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

yummy = JFormattedTextField
stupid = JFormattedTextField
Commit is only for SQL supposedly? How do I make it work with java?
Errors:
 
Greenhorn
Posts: 2
Eclipse IDE Java Ubuntu
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 48
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 4568
9
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic