Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EXIT_ON_CLOSE variable error

 
orgil khatanbaatar
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



why is it giving error : "Can not find the symbol EXIT_ON_CLOSE variable"?
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because EXIT_ON_CLOSE doesn't exist in the JFrame class. It's in WindowConstants. Look at the Javadocs for the setDefaultCloseOperation method.
 
orgil khatanbaatar
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matthew Brown wrote:Because EXIT_ON_CLOSE doesn't exist in the JFrame class. It's in WindowConstants. Look at the Javadocs for the setDefaultCloseOperation method.


No fair. but other codes worked fine so far. I will give an example.

 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matthew Brown wrote:Because EXIT_ON_CLOSE doesn't exist in the JFrame class. It's in WindowConstants.

Um, JFrame implements WindowConstants.
 
Matthew Brown
Bartender
Posts: 4568
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good point . Didn't think that through, and was looking for a simple answer. In that case it's a little strange...

Ah, got it. It should be JFrame.EXIT_ON_CLOSE, not JFrame.EXIT_ON_CL0SE. Spot the difference? Convert it to lower case and it's more obvious.
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
orgil , your code doesn't follow the coding conventions and is extremely difficult to read. It's in your own interest to make the code easily readable, as that will get you more readers and quicker/better responses.

You have a typo in EXIT_ON_CL0SE. Look carefully at these two characters: O 0 -- see the difference?

Here's your code with the typo corrected and with class names and indents that conform to convention.
 
orgil khatanbaatar
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you awesome guys getting tiny error for me. Sorry for inconvenience of coding!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic