0

I'm trying to activate revalidate method in a class that extends JFrame but just can't. this is my first experience with swing, and I used to have java 6 until today, since I couldn't use revalidate I installed JDK 1.7.0_21 but still can't use it. I use eclipse, and it says "The method revalidate() is undefined for the type Game"(Game is my class that extends JFrame)

Also, when I tried writing revalidate in the exact same place in the code, on windows computer, it was o.k

I couldn't find anything about this topic..

I'm on OSX 10.8.3...

Any help will be appreciated, thanks!

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Hagai
  • 678
  • 7
  • 20

1 Answers1

1

JFrame#revalidate (from java.awt.Component) was added in Java 7. With Java being cross platform, JDKs and JREs have this method also. Therefore it is very likely that Eclipse is still using Java 6.

Right click on the project and click on

  • Properties > Java Build Path > Libraries
  • Select JRE System Library (1.6) -> Click Remove

Then add JRE for Java 7

  • Add Library > JRE System Library > Installed JREs
  • Select JDK 1.7 > OK > Finish
Reimeus
  • 158,255
  • 15
  • 216
  • 276
  • No problem (always glad to fix those). Compliance level refers to syntax (eg, if you set compliance to 1.6 (or lower), you won't be allowed to use the diamond (`<>`)). JRE system library refers to the libraries available in a JRE (ie, the jars and the contained classes) so this enforces the use of the appropriate API's and available methods. Cheers :-) – Guillaume Polet Jun 05 '13 at 19:31
  • Wow thanks for the quick reply!! worked just great, by the way this is how I added java 7 to eclipse http://stackoverflow.com/questions/6267392/how-do-i-use-jdk-7-on-mac-osx – Hagai Jun 06 '13 at 07:26